openDialog.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div class="Dialog-box">
  3. <el-dialog
  4. :visible.sync="isOpenDialog"
  5. :close-on-click-modal="false"
  6. :modal-append-to-body='false'
  7. @close="cancelHandle"
  8. custom-class="dialog"
  9. center
  10. width="560px"
  11. v-dialogDrag>
  12. <div slot="title" style="display:flex;alignItems:center;">
  13. <img :src="title=='添加'?$icons.add:title=='编辑'?$icons.edit:''" style="color:#fff;width:16px;height:16px;marginRight:5px;">
  14. <span style="fontSize:16px;">{{title==='添加' ? $t('Table.add_btn') : $t('Table.edit_btn')}}</span>
  15. </div>
  16. <div class="dialog-main">
  17. <el-form
  18. ref="diaForm"
  19. label-position="left"
  20. hide-required-asterisk
  21. label-width="120px"
  22. :model="formData"
  23. :rules="formRules">
  24. <template v-if="!formData.isEDB">
  25. <el-form-item :label="$t('EtaBasePage.parent_menu')" v-if="formData.level>0">
  26. <el-tooltip class="item" effect="dark" :content="getParentName" placement="top">
  27. <span class="parentStr">{{getParentName}}</span>
  28. </el-tooltip>
  29. </el-form-item>
  30. <el-form-item :label="$t('EtaBasePage.menu_name')" prop="levelVal">
  31. <el-input
  32. v-model="formData.levelVal"
  33. style="width: 80%"
  34. :placeholder="$t('Dialog.require_vaild')"></el-input>
  35. </el-form-item>
  36. </template>
  37. <!-- 编辑具体指标 -->
  38. <template v-if="title=='编辑' && formData.isEDB">
  39. <el-form-item :label="$t('Edb.Detail.e_name')" prop="levelVal">
  40. <el-input
  41. v-model="formData.levelVal"
  42. style="width: 80%"
  43. :placeholder="$t('Edb.InputHolderAll.input_name')"></el-input>
  44. </el-form-item>
  45. <el-form-item :label="$t('Edb.Detail.e_menu')" prop="level_menu">
  46. <cascader
  47. v-model="formData.level_menu"
  48. :options="options"
  49. cascaderWidth="width: 80%"
  50. :placeholder="$t('Edb.InputHolderAll.input_menu')"
  51. :config="{ checkStrictly: true }"
  52. />
  53. </el-form-item>
  54. <el-form-item :label="$t('Edb.Detail.e_fre')" prop="frequency">
  55. <!-- <span slot="label">频&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;率</span> -->
  56. <el-select
  57. v-model="formData.frequency"
  58. :placeholder="$t('Edb.InputHolderAll.input_fre')"
  59. style="width:80%"
  60. :disabled="$parent.tableData[0].Source===58"
  61. @change="changeTrade">
  62. <el-option
  63. v-for="item in frequencyArr"
  64. :key="item"
  65. :label="item"
  66. :value="item">
  67. </el-option>
  68. </el-select>
  69. </el-form-item>
  70. <el-form-item :label="$t('Edb.Detail.e_unit')" prop="unit">
  71. <!-- <span slot="label">单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位</span> -->
  72. <selectUnit v-model="formData.unit" style="width: 80%" />
  73. </el-form-item>
  74. </template>
  75. </el-form>
  76. </div>
  77. <div class="dia-bot">
  78. <el-button type="primary" style="margin-right:20px" @click="saveHandle"><!-- 保存 -->{{$t('Dialog.confirm_save_btn')}}</el-button>
  79. <el-button type="primary" plain @click="cancelHandle"><!-- 取消 -->{{$t('Dialog.cancel_btn')}}</el-button>
  80. </div>
  81. </el-dialog>
  82. </div>
  83. </template>
  84. <script>
  85. import { dataBaseInterface } from '@/api/api.js';
  86. import { unitArr } from '@/utils/defaultOptions';
  87. import { frequencyArr } from './util'
  88. import apiIntervalAnalysis from '@/api/modules/intervalAnalysis'
  89. export default {
  90. props: {
  91. isOpenDialog: {
  92. type: Boolean,
  93. },
  94. //标题
  95. title: {
  96. type: String,
  97. default: '添加'
  98. },
  99. formData: {
  100. type: Object,//{parentArr父级数据,isEDB:true 是否为指标}
  101. }
  102. },
  103. watch: {
  104. 'isOpenDialog': {
  105. handler(newval) {
  106. if(newval && this.formData.isEDB) {
  107. this.getMenu();
  108. }
  109. // console.log(this.formData);
  110. }
  111. }
  112. },
  113. computed:{
  114. getParentName(){
  115. const arr=this.formData.parentArr||[]
  116. let strArr=arr.reverse().map(item=>{
  117. return this.currentLang==='en'?item.classifyNameEn:item.classifyName
  118. })
  119. return strArr.join('/')
  120. }
  121. },
  122. data () {
  123. return {
  124. formRules: {
  125. levelVal:[
  126. { required: true, message: this.$t('EtaBasePage.input_menu_msg'), trigger: 'blur' },
  127. ],
  128. // level_2:[
  129. // { required: true, message: '目录名称不能为空', trigger: 'blur' },
  130. // ],
  131. // level_3:[
  132. // { required: true, message: '目录名称不能为空', trigger: 'blur' },
  133. // ],
  134. // level_4:[
  135. // { required: true, message: '指标名称不能为空', trigger: 'blur' },
  136. // ],
  137. level_menu:[
  138. { required: true, message: this.$t('Edb.Valids.menu_msg'), trigger: 'blur' },
  139. ],
  140. frequency:[
  141. { required: true, message: this.$t('Edb.Valids.fre_msg'), trigger: 'blur' },
  142. ],
  143. unit:[
  144. { required: true, message: this.$t('Edb.Valids.unit_msg'), trigger: ['blur','change'] },
  145. ],
  146. },
  147. options: [],
  148. unitArr,
  149. levelProps: {
  150. label: 'ClassifyName',
  151. value: 'ClassifyId',
  152. children: 'Children',
  153. checkStrictly: true
  154. },
  155. frequencyArr,
  156. };
  157. },
  158. methods: {
  159. async saveHandle() {
  160. await this.$refs.diaForm.validate();
  161. let res = null;
  162. if(this.title==='添加') {
  163. // 区间分析
  164. if(this.$route.path==='/rangeAnalysis'){
  165. res=await apiIntervalAnalysis.classifyAdd({
  166. ChartClassifyName:this.formData.levelVal||'',
  167. ParentId:this.formData.parent_id || 0,
  168. Level: this.formData.level
  169. })
  170. }else{
  171. res = await dataBaseInterface.nodeAdd({
  172. ClassifyName: this.formData.levelVal||'',
  173. ParentId:this.formData.parent_id || 0,
  174. Level: this.formData.level
  175. })
  176. }
  177. }else if(this.title==='编辑') {
  178. // 区间分析
  179. if(this.$route.path==='/rangeAnalysis'){
  180. res=await apiIntervalAnalysis.classifyEdit({
  181. ChartClassifyId: this.formData.classify_id || 0,
  182. ChartClassifyName: this.formData.levelVal||''
  183. })
  184. }else{
  185. res = this.formData.isEDB
  186. ? await dataBaseInterface.targetEdit({
  187. ClassifyId: this.formData.level_menu[this.formData.level_menu.length - 1],
  188. EdbInfoId: this.formData.edbinfo_id,
  189. EdbName: this.formData.levelVal,
  190. Frequency: this.formData.frequency,
  191. Unit: this.formData.unit
  192. })
  193. : await dataBaseInterface.nodeEdit({
  194. ClassifyName: this.formData.levelVal||'',
  195. ClassifyId:this.formData.classify_id || 0
  196. })
  197. }
  198. }
  199. if(res.Ret !== 200) return
  200. this.$message.success(res.Msg);
  201. if(this.title==='添加') this.callbackHandle('add');
  202. else if(this.title==='编辑' && this.formData.isEDB) this.callbackHandle('update');
  203. else if(this.title==='编辑' && !this.formData.isEDB) this.callbackHandle();
  204. },
  205. /* 成功回调 */
  206. callbackHandle(type) {
  207. this.$refs.diaForm.resetFields();
  208. this.$emit('sucessCallback',type)
  209. },
  210. /* 取消 */
  211. cancelHandle() {
  212. this.$refs.diaForm.resetFields();
  213. this.$emit('closeDia')
  214. },
  215. /* 获取目录结构 */
  216. getMenu() {
  217. dataBaseInterface.menuListV3().then(res => {
  218. if(res.Ret === 200) {
  219. this.filterNodes(res.Data.AllNodes||[]);
  220. this.options = res.Data.AllNodes || [];
  221. }
  222. })
  223. },
  224. // 递归改变第三级目录结构
  225. filterNodes(arr) {
  226. arr.length && arr.forEach(item => {
  227. item.Children.length && this.filterNodes(item.Children)
  228. if(!item.Children.length) {
  229. delete item.Children
  230. }
  231. })
  232. }
  233. },
  234. created() {},
  235. mounted() {},
  236. }
  237. </script>
  238. <style lang='scss'>
  239. .Dialog-box {
  240. .parentStr{
  241. display: block;
  242. width: 304px;
  243. overflow: hidden;
  244. white-space: nowrap;
  245. text-overflow: ellipsis;
  246. }
  247. .dialog-main {
  248. padding-left: 50px;
  249. }
  250. .el-cascader .el-input {
  251. width: 100%;
  252. }
  253. .dia-bot {
  254. margin: 52px 0 30px;
  255. display: flex;
  256. justify-content: center;
  257. }
  258. }
  259. </style>