saveEdbToBaseDia.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div class="editTargetDiaBase-box">
  3. <el-dialog
  4. :visible.sync="isShow"
  5. :close-on-click-modal="false"
  6. :modal-append-to-body='false'
  7. @close="cancelHandle"
  8. custom-class="dialog"
  9. center
  10. width="700px"
  11. :title="saveScence==='saveOther' ? $t('StatisticAnalysis.ChartRelevance.save_other'):$t('StatisticAnalysis.ChartRelevance.save_edb')"
  12. v-dialogDrag>
  13. <div class="dialog-main">
  14. <el-form
  15. ref="targetForm"
  16. label-position="left"
  17. label-width="120px"
  18. hide-required-asterisk
  19. :model="formData"
  20. :rules="formRules">
  21. <el-form-item :label="$t('Table.edb_name')" prop="edb_name">
  22. <el-input
  23. v-model="formData.edb_name"
  24. style="width: 80%"
  25. :placeholder="$t('Table.edb_name')"></el-input>
  26. </el-form-item>
  27. <el-form-item :label="$t('Edb.Detail.select_catalogue')" prop="menu">
  28. <cascader
  29. v-model="formData.menu"
  30. :options="options"
  31. clearable
  32. cascaderWidth="width:80%"
  33. :placeholder="
  34. $t('CustomAnalysisPage.select_appropriate_category')
  35. "
  36. :config="{ emitPath: false, checkStrictly: true }"
  37. />
  38. </el-form-item>
  39. <el-form-item :label="$t('Table.frequency')" prop="frequency">
  40. <span slot="label">{{$t('Table.frequency')}}</span>
  41. <el-select
  42. v-model="formData.frequency"
  43. :placeholder="$t('CustomAnalysisPage.select_frequency')"
  44. style="width:80%"
  45. clearable>
  46. <el-option
  47. v-for="item in frequencyArr"
  48. :key="item.value"
  49. :label="item.label"
  50. :value="item.value">
  51. </el-option>
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item :label="$t('Table.unit')" prop="unit">
  55. <span slot="label">{{$t('Table.unit')}}</span>
  56. <selectUnit
  57. v-model="formData.unit"
  58. style="width: 80%"
  59. />
  60. </el-form-item>
  61. </el-form>
  62. </div>
  63. <div class="dia-bot">
  64. <el-button type="primary" style="margin-right:20px" @click="addTarget">{{$t('Dialog.confirm_save_btn')}}</el-button>
  65. <el-button type="primary" plain @click="cancelHandle">{{$t('Dialog.cancel_btn')}}</el-button>
  66. </div>
  67. </el-dialog>
  68. </div>
  69. </template>
  70. <script>
  71. import { dataBaseInterface } from '@/api/api.js';
  72. import * as preDictEdbInterface from '@/api/modules/predictEdbApi.js';
  73. import chartRelevanceApi,{ statisticFeatureInterface } from '@/api/modules/chartRelevanceApi.js';
  74. import { unitArr,frequencySelectList } from '@/utils/defaultOptions';
  75. import selectUnit from '@/components/selectUnit.vue';
  76. export default {
  77. components: { selectUnit },
  78. props: {
  79. isShow: {
  80. type: Boolean,
  81. },
  82. chartData: {
  83. type: Object,
  84. },
  85. source: {
  86. type: Number
  87. },
  88. saveScence: { //saveOther另存为 ''保存
  89. type:String,
  90. default: ''
  91. },
  92. },
  93. watch: {
  94. 'isShow': {
  95. handler(newval) {
  96. newval && this.getMenu();
  97. const { ChartName } = this.chartData;
  98. this.formData.edb_name = this.saveScence==='saveOther' ? `${ChartName}(1)` : ChartName;
  99. }
  100. }
  101. },
  102. computed:{
  103. formRules(){
  104. return {
  105. edb_name:[
  106. { required: true, message: /* '指标名称不能为空' */this.$t('Edb.Valids.name_msg'), trigger: 'blur' },
  107. ],
  108. menu:[
  109. { required: true, message: /* '所属目录不能为空' */this.$t('Edb.Valids.menu_msg'), trigger: 'blur' },
  110. ],
  111. frequency:[
  112. { required: true, message: /* '频率不能为空' */this.$t('Edb.Valids.fre_msg'), trigger: 'blur' },
  113. ],
  114. unit:[
  115. { required: true, message: /* '单位不能为空' */this.$t('Edb.Valids.unit_msg'), trigger: 'blur' },
  116. ],
  117. }
  118. }
  119. },
  120. data () {
  121. return {
  122. formData: {
  123. edb_name:'',
  124. menu:'',
  125. frequency: '',
  126. unit:''
  127. },
  128. options: [],
  129. unitArr,
  130. levelProps: {
  131. label: 'ClassifyName',
  132. value: 'ClassifyId',
  133. children: 'Children',
  134. emitPath: false,
  135. checkStrictly: true
  136. },
  137. frequencyArr:frequencySelectList(),
  138. };
  139. },
  140. methods: {
  141. /* 获取目录结构 */
  142. async getMenu() {
  143. let res;
  144. //统计特征区分原指标是否预测,保存到预测指标库或/eta指标库
  145. if(this.$route.path==='/statisticFeatureChartEditor'&&this.$parent.oldEdbInfoType) {
  146. res = await preDictEdbInterface.classifyListV2()
  147. if(res.Ret !== 200) return
  148. }else {
  149. res = await dataBaseInterface.menuListV3({ClassifyType:2})
  150. if(res.Ret !== 200) return
  151. }
  152. this.filterNodes(res.Data.AllNodes||[]);
  153. this.options = res.Data.AllNodes || [];
  154. },
  155. filterNodes(arr,n) {
  156. arr.length && arr.forEach(item => {
  157. item.Children && item.Children.length && this.filterNodes(item.Children,n)
  158. if(!item.Children.length) {
  159. delete item.Children
  160. }
  161. })
  162. },
  163. /* 保存 */
  164. async addTarget() {
  165. await this.$refs.targetForm.validate()
  166. const { edb_name,menu,frequency,unit } = this.formData;
  167. //统计图的2 3 4对应source8 9 10但其实图表source又是7 8 9 别问为什么这样搞问后端 我也乱的一批
  168. const sourceMap = {
  169. 1: 1,
  170. 2: 8,
  171. 3: 9,
  172. 4: 10
  173. }
  174. let Source;
  175. if(['/relevancechartEditor','/relevancechartEditorV2'].includes(this.$route.path)) {
  176. Source = this.source;
  177. }else if(this.$route.path==='/statisticFeatureChartEditor') {
  178. Source = sourceMap[this.source]
  179. }
  180. let params = {
  181. Source,
  182. IsSaveAs: this.saveScence==='saveOther',
  183. EdbName: edb_name,
  184. Frequency: frequency,
  185. Unit: unit,
  186. ClassifyId: menu,
  187. ...this.$parent.chartInfo
  188. }
  189. let res = null;
  190. if(['/relevancechartEditor','/relevancechartEditorV2'].includes(this.$route.path)) {
  191. res = await chartRelevanceApi.saveEdb(params);
  192. }else if(this.$route.path==='/statisticFeatureChartEditor') {
  193. res = await statisticFeatureInterface.saveEdb(params);
  194. }
  195. if(res.Ret !== 200) return
  196. this.$message.success(/* '保存成功' */this.$t('MsgPrompt.saved_msg'));
  197. this.cancelHandle();
  198. this.$emit('saveBack',{source:this.source})
  199. },
  200. cancelHandle() {
  201. this.formData = {
  202. edb_name:'',
  203. menu:'',
  204. frequency: '',
  205. unit:''
  206. }
  207. this.$emit('update:isShow',false)
  208. }
  209. },
  210. }
  211. </script>
  212. <style lang='scss'>
  213. .editTargetDiaBase-box {
  214. .dialog-main {
  215. padding-left: 50px;
  216. }
  217. .el-cascader .el-input {
  218. width: 100%;
  219. }
  220. .dia-bot {
  221. margin: 52px 0 30px;
  222. display: flex;
  223. justify-content: center;
  224. }
  225. }
  226. </style>