123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <template>
- <div class="Dialog-box">
- <el-dialog
- :visible.sync="isOpenDialog"
- :close-on-click-modal="false"
- :modal-append-to-body='false'
- @close="cancelHandle"
- custom-class="dialog"
- center
- width="560px"
- v-dialogDrag>
- <div slot="title" style="display:flex;alignItems:center;">
- <img :src="title=='添加'?$icons.add:title=='编辑'?$icons.edit:''" style="color:#fff;width:16px;height:16px;marginRight:5px;">
- <span style="fontSize:16px;">{{title==='添加' ? $t('Table.add_btn') : $t('Table.edit_btn')}}</span>
- </div>
- <div class="dialog-main">
- <el-form
- ref="diaForm"
- label-position="left"
- hide-required-asterisk
- label-width="120px"
- :model="formData"
- :rules="formRules">
- <template v-if="!formData.isEDB">
- <el-form-item :label="$t('EtaBasePage.parent_menu')" v-if="formData.level>0">
- <el-tooltip class="item" effect="dark" :content="getParentName" placement="top">
- <span class="parentStr">{{getParentName}}</span>
- </el-tooltip>
- </el-form-item>
- <el-form-item :label="$t('EtaBasePage.menu_name')" prop="levelVal">
- <el-input
- v-model="formData.levelVal"
- style="width: 80%"
- :placeholder="$t('Dialog.require_vaild')"></el-input>
- </el-form-item>
- </template>
- <!-- 编辑具体指标 -->
- <template v-if="title=='编辑' && formData.isEDB">
- <el-form-item :label="$t('Edb.Detail.e_name')" prop="levelVal">
- <el-input
- v-model="formData.levelVal"
- style="width: 80%"
- :placeholder="$t('Edb.InputHolderAll.input_name')"></el-input>
- </el-form-item>
- <el-form-item :label="$t('Edb.Detail.e_menu')" prop="level_menu">
- <cascader
- v-model="formData.level_menu"
- :options="options"
- cascaderWidth="width: 80%"
- :placeholder="$t('Edb.InputHolderAll.input_menu')"
- :config="{ checkStrictly: true }"
- />
- </el-form-item>
- <el-form-item :label="$t('Edb.Detail.e_fre')" prop="frequency">
- <!-- <span slot="label">频 率</span> -->
- <el-select
- v-model="formData.frequency"
- :placeholder="$t('Edb.InputHolderAll.input_fre')"
- style="width:80%"
- :disabled="$parent.tableData[0].Source===58"
- @change="changeTrade">
- <el-option
- v-for="item in frequencyArr"
- :key="item"
- :label="item"
- :value="item">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item :label="$t('Edb.Detail.e_unit')" prop="unit">
- <!-- <span slot="label">单 位</span> -->
- <selectUnit v-model="formData.unit" style="width: 80%" />
- </el-form-item>
- </template>
- </el-form>
- </div>
- <div class="dia-bot">
- <el-button type="primary" style="margin-right:20px" @click="saveHandle"><!-- 保存 -->{{$t('Dialog.confirm_save_btn')}}</el-button>
- <el-button type="primary" plain @click="cancelHandle"><!-- 取消 -->{{$t('Dialog.cancel_btn')}}</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { dataBaseInterface } from '@/api/api.js';
- import { unitArr } from '@/utils/defaultOptions';
- import { frequencyArr } from './util'
- import apiIntervalAnalysis from '@/api/modules/intervalAnalysis'
- export default {
- props: {
- isOpenDialog: {
- type: Boolean,
- },
- //标题
- title: {
- type: String,
- default: '添加'
- },
- formData: {
- type: Object,//{parentArr父级数据,isEDB:true 是否为指标}
- }
- },
- watch: {
- 'isOpenDialog': {
- handler(newval) {
- if(newval && this.formData.isEDB) {
- this.getMenu();
- }
- // console.log(this.formData);
- }
- }
- },
- computed:{
- getParentName(){
- const arr=this.formData.parentArr||[]
- let strArr=arr.reverse().map(item=>{
- return this.currentLang==='en'?item.classifyNameEn:item.classifyName
- })
-
- return strArr.join('/')
- }
- },
- data () {
- return {
- formRules: {
- levelVal:[
- { required: true, message: this.$t('EtaBasePage.input_menu_msg'), trigger: 'blur' },
- ],
- // level_2:[
- // { required: true, message: '目录名称不能为空', trigger: 'blur' },
- // ],
- // level_3:[
- // { required: true, message: '目录名称不能为空', trigger: 'blur' },
- // ],
- // level_4:[
- // { required: true, message: '指标名称不能为空', trigger: 'blur' },
- // ],
- level_menu:[
- { required: true, message: this.$t('Edb.Valids.menu_msg'), trigger: 'blur' },
- ],
- frequency:[
- { required: true, message: this.$t('Edb.Valids.fre_msg'), trigger: 'blur' },
- ],
- unit:[
- { required: true, message: this.$t('Edb.Valids.unit_msg'), trigger: ['blur','change'] },
- ],
- },
- options: [],
- unitArr,
- levelProps: {
- label: 'ClassifyName',
- value: 'ClassifyId',
- children: 'Children',
- checkStrictly: true
- },
- frequencyArr,
- };
- },
- methods: {
- async saveHandle() {
- await this.$refs.diaForm.validate();
- let res = null;
- if(this.title==='添加') {
- // 区间分析
- if(this.$route.path==='/rangeAnalysis'){
- res=await apiIntervalAnalysis.classifyAdd({
- ChartClassifyName:this.formData.levelVal||'',
- ParentId:this.formData.parent_id || 0,
- Level: this.formData.level
- })
- }else{
- res = await dataBaseInterface.nodeAdd({
- ClassifyName: this.formData.levelVal||'',
- ParentId:this.formData.parent_id || 0,
- Level: this.formData.level
- })
- }
-
- }else if(this.title==='编辑') {
- // 区间分析
- if(this.$route.path==='/rangeAnalysis'){
- res=await apiIntervalAnalysis.classifyEdit({
- ChartClassifyId: this.formData.classify_id || 0,
- ChartClassifyName: this.formData.levelVal||''
- })
- }else{
- res = this.formData.isEDB
- ? await dataBaseInterface.targetEdit({
- ClassifyId: this.formData.level_menu[this.formData.level_menu.length - 1],
- EdbInfoId: this.formData.edbinfo_id,
- EdbName: this.formData.levelVal,
- Frequency: this.formData.frequency,
- Unit: this.formData.unit
- })
- : await dataBaseInterface.nodeEdit({
- ClassifyName: this.formData.levelVal||'',
- ClassifyId:this.formData.classify_id || 0
- })
- }
-
- }
- if(res.Ret !== 200) return
- this.$message.success(res.Msg);
- if(this.title==='添加') this.callbackHandle('add');
- else if(this.title==='编辑' && this.formData.isEDB) this.callbackHandle('update');
- else if(this.title==='编辑' && !this.formData.isEDB) this.callbackHandle();
-
- },
- /* 成功回调 */
- callbackHandle(type) {
- this.$refs.diaForm.resetFields();
- this.$emit('sucessCallback',type)
- },
- /* 取消 */
- cancelHandle() {
- this.$refs.diaForm.resetFields();
- this.$emit('closeDia')
- },
-
- /* 获取目录结构 */
- getMenu() {
- dataBaseInterface.menuListV3().then(res => {
- if(res.Ret === 200) {
- this.filterNodes(res.Data.AllNodes||[]);
- this.options = res.Data.AllNodes || [];
- }
- })
- },
- // 递归改变第三级目录结构
- filterNodes(arr) {
- arr.length && arr.forEach(item => {
- item.Children.length && this.filterNodes(item.Children)
- if(!item.Children.length) {
- delete item.Children
- }
- })
- }
- },
- created() {},
- mounted() {},
- }
- </script>
- <style lang='scss'>
- .Dialog-box {
- .parentStr{
- display: block;
- width: 304px;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .dialog-main {
- padding-left: 50px;
- }
- .el-cascader .el-input {
- width: 100%;
- }
- .dia-bot {
- margin: 52px 0 30px;
- display: flex;
- justify-content: center;
- }
- }
- </style>
|