index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. <template>
  2. <div class='point-box'>
  3. <div class='left'>
  4. <ul>
  5. <li>
  6. <span>原始点位信息</span>&nbsp;&nbsp;&nbsp;
  7. <span :title="editData.Point.Description || '--'">{{editData.Point.Description || '--'}}</span>
  8. </li>
  9. <li>
  10. <span>位置标签</span>&nbsp;&nbsp;&nbsp;
  11. <span :title="editData.Point.LocationFlag.toString() || '--'">{{editData.Point.LocationFlag.toString() || '--'}}</span>
  12. </li>
  13. <li>
  14. <span>对象类型</span>&nbsp;&nbsp;&nbsp;
  15. <span :title="editData.Point.KeyEquipmentType || '--'">{{editData.Point.KeyEquipmentType || '--'}}</span>
  16. </li>
  17. <li>
  18. <span>对象参数</span>&nbsp;&nbsp;&nbsp;
  19. <span :title="editData.Point.KeyEquipmentParameter || '--'">{{editData.Point.KeyEquipmentParameter || '--'}}</span>
  20. </li>
  21. <li>
  22. <span>值/单位说明</span>&nbsp;&nbsp;&nbsp;
  23. <span :title="editData.Point.ValueDescription || '--'">{{editData.Point.ValueDescription || '--'}}</span>
  24. </li>
  25. <li>
  26. <span>备注</span>&nbsp;&nbsp;&nbsp;
  27. <span :title="editData.Point.Remarks || '--'">{{editData.Point.Remarks || '--'}}</span>
  28. </li>
  29. </ul>
  30. </div>
  31. <div class='right'>
  32. <el-form class='form' :rules='rules' ref='form' :model='form' label-width='140px'>
  33. <el-form-item label='对应数据字典' prop='diction'>
  34. <dictionary-cas @change="changeDictionaryCas" ref="dictionaryCas"></dictionary-cas>
  35. </el-form-item>
  36. <el-form-item label='对象标识' prop="EquipmentMark">
  37. <el-input v-model='form.EquipmentMark'></el-input>
  38. </el-form-item>
  39. <template v-for="(it,index) in typeList">
  40. <div class='dict' :key="index">
  41. <label class="el-form-item__label" style="width:140px;">信息点名称:</label><span style="line-height:40px">{{it.name||''}}</span>
  42. <p class='btm'>
  43. <el-input readonly type='textarea' :rows='2' placeholder='信息点的单位及值的说明' v-model='it.ValueDescription'>
  44. </el-input>
  45. <el-form-item style="margin-top:15px;" label='值处理方式' prop='DataRuleType'>
  46. <el-select v-model='it.DataRuleType' placeholder='请选择'>
  47. <el-option v-for='item in handleTypeArr' :key='item.value' :label='item.label' :value='item.value'></el-option>
  48. </el-select>
  49. </el-form-item>
  50. </p>
  51. <!-- components -->
  52. <no-handle :ref='"noHandle"+index' v-if='it.DataRuleType == "无需处理,直接使用"' :noHandleShow='noHandleShow'></no-handle>
  53. <auto-handle :ref='"autoHandle"+index' v-else-if='it.DataRuleType == "需自动单位转换"' :unitObj='it.unitObj' :autoHandleShow='autoHandleShow'>
  54. </auto-handle>
  55. <enum-handle :ref='"enumHandle"+index' v-else-if='it.DataRuleType == "需按设置枚举转换"' :enumHandleShow='enumHandleShow'></enum-handle>
  56. <formula-handle :ref='"formulaHandle"+index' v-else-if='it.DataRuleType == "需按公式转换"' :formulaHandleShow='formulaHandleShow'>
  57. </formula-handle>
  58. <split-handle :ref='"splitHandle"+index' v-else-if='it.DataRuleType == "需拆分处理"' :splitHandleShow='splitHandleShow'></split-handle>
  59. </div>
  60. </template>
  61. </el-form>
  62. <div class='btn-box'>
  63. <el-button type='primary' @click='save' :disabled="!cacheTime" :loading="!cacheTime">保存</el-button>
  64. </div>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. //components
  70. import noHandle from './no_handle'
  71. import autoHandle from './auto_handle'
  72. import enumHandle from './enum_handle'
  73. import formulaHandle from './formula_handle'
  74. import splitHandle from './split_handle'
  75. import { mapGetters, mapActions } from 'vuex'
  76. //api
  77. import { getEquipmentAll, getQueryProperty } from '@/fetch/data_plat'
  78. import { updatePoint, batchCreate } from '@/fetch/point_http'
  79. import dictionaryCas from '@/components/config_point/dictionaryCascader'
  80. export default {
  81. name: 'point_config_step3_edit',
  82. computed: {
  83. ...mapGetters('project', ['projectId', 'datasourceId', 'protocolType', 'cacheTime'])
  84. },
  85. data() {
  86. return {
  87. options: [],
  88. optionObj: {},
  89. infoDict: {}, //信息点字典
  90. dataDict: {}, //数据字典
  91. InfomationPoint: null, //信息点
  92. unitObj: {}, //传给自动单位转换的obj
  93. ValueDescription: {}, //值/点位描述
  94. form: {
  95. diction: '1',//占位
  96. DataRuleType: '无需处理,直接使用',
  97. EquipmentMark: ''
  98. },
  99. rules: {
  100. DataRuleType: [{ required: true, message: '请选择值处理方式', trigger: 'change' }],
  101. diction: [{ required: true }],
  102. EquipmentMark: [{ required: true, message: '请输入对象标识', trigger: 'blur' }],
  103. },
  104. handleTypeArr: [
  105. {
  106. label: '无需处理,直接使用',
  107. value: '无需处理,直接使用'
  108. },
  109. {
  110. label: '需自动单位转换',
  111. value: '需自动单位转换'
  112. },
  113. {
  114. label: '需按设置枚举转换',
  115. value: '需按设置枚举转换'
  116. },
  117. {
  118. label: '需按公式转换',
  119. value: '需按公式转换'
  120. },
  121. {
  122. label: '需拆分处理',
  123. value: '需拆分处理'
  124. }
  125. ],
  126. /**值回显******* */
  127. noHandleShow: {},
  128. autoHandleShow: {},
  129. enumHandleShow: {},
  130. formulaHandleShow: {},
  131. splitHandleShow: {},
  132. dictionaryData: [],
  133. typeList: [],
  134. pointToRelationID: {}, //保存信息点->relationid map
  135. }
  136. },
  137. props: {
  138. editData: {
  139. type: Object,
  140. default: {}
  141. }
  142. },
  143. components: {
  144. noHandle,
  145. autoHandle,
  146. enumHandle,
  147. formulaHandle,
  148. splitHandle,
  149. dictionaryCas
  150. },
  151. methods: {
  152. //保存
  153. save() {
  154. if (!this.form.EquipmentMark) {
  155. this.errMsg();
  156. return false;
  157. }
  158. this.$refs.dictionaryCas.validate(valid => {
  159. if (valid) {
  160. for (let i = 0; i < this.typeList.length; i++) {
  161. let flag = this.typeList[i].DataRuleType
  162. switch (flag) {
  163. case '无需处理,直接使用':
  164. let componnoHandle = `noHandle${i}`
  165. this.$refs[componnoHandle][0].getForm(noHandle => {
  166. if (noHandle) {
  167. this.typeList[i].other = noHandle
  168. // this.saveForm(this.form, noHandle)
  169. } else {
  170. this.errMsg();
  171. return false;
  172. }
  173. })
  174. break
  175. case '需自动单位转换':
  176. let componautoHandle = `autoHandle${i}`
  177. this.$refs[componautoHandle][0].getForm(autoHandle => {
  178. if (autoHandle) {
  179. this.typeList[i].other = autoHandle
  180. // this.saveForm(this.form, autoHandle)
  181. } else {
  182. this.errMsg()
  183. return false;
  184. }
  185. })
  186. break
  187. case '需按设置枚举转换':
  188. let componenumHandle = `enumHandle${i}`
  189. this.$refs[componenumHandle][0].getForm(enumHandle => {
  190. if (enumHandle) {
  191. this.typeList[i].other = enumHandle
  192. // this.saveForm(this.form, enumHandle)
  193. } else {
  194. this.errMsg()
  195. return false;
  196. }
  197. })
  198. break
  199. case '需按公式转换':
  200. let componformulaHandle = `formulaHandle${i}`
  201. this.$refs[componformulaHandle][0].getForm(formulaHandle => {
  202. if (formulaHandle) {
  203. this.typeList[i].other = formulaHandle
  204. // this.saveForm(this.form, formulaHandle)
  205. } else {
  206. this.errMsg()
  207. return false;
  208. }
  209. })
  210. break
  211. case '需拆分处理':
  212. let componsplitHandle = `splitHandle${i}`
  213. this.$refs[componsplitHandle][0].getForm(splitHandle => {
  214. if (splitHandle) {
  215. this.typeList[i].other = splitHandle
  216. // this.saveForm(this.form, splitHandle)
  217. } else {
  218. this.errMsg()
  219. return false;
  220. }
  221. })
  222. break
  223. }
  224. }
  225. this.saveForm()
  226. } else {
  227. this.errMsg()
  228. return false
  229. }
  230. })
  231. },
  232. saveForm() {
  233. let updateParams = {
  234. data: {
  235. Content: [{ Id: this.editData.Point.Id }]
  236. },
  237. type: this.protocolType
  238. }
  239. let params = this.typeList.map((t, i) => {
  240. let temp = this.dictionaryData[i],
  241. tempNames = t.name.split('-');
  242. let eachData = {
  243. InfomationPointCode: temp[temp.length - 1],
  244. InfomationPoint: tempNames[tempNames.length - 1],
  245. DataRuleType: t.DataRuleType,
  246. DataSourceId: this.datasourceId, //数据源id
  247. PointId: this.editData.Point.Id, //点位ID
  248. TypeCode: temp[0],
  249. Type: tempNames[0],
  250. EquipmentMark: this.form.EquipmentMark
  251. }
  252. if (temp.length == 3) {
  253. //设备-部件-空间
  254. eachData.EquipmentTypeCode = temp[1]
  255. eachData.EquipmentType = tempNames[1]
  256. let key = `${eachData.TypeCode}-${eachData.EquipmentTypeCode}-${eachData.InfomationPointCode}`
  257. if (this.pointToRelationID[key]) {
  258. eachData.Id = this.pointToRelationID[key]
  259. }
  260. } else if (temp.length == 4) {
  261. eachData.SpecialtyCode = temp[1]
  262. eachData.Specialty = tempNames[1]
  263. eachData.SystemCode = temp[2]
  264. eachData.System = tempNames[2]
  265. eachData.EquipmentTypeCode = eachData.SystemCode //为了配置从动参取值存储
  266. eachData.EquipmentType = eachData.System
  267. let key = `${eachData.TypeCode}-${eachData.SpecialtyCode}-${eachData.SystemCode}-${eachData.InfomationPointCode}`
  268. if (this.pointToRelationID[key]) {
  269. eachData.Id = this.pointToRelationID[key]
  270. }
  271. } else if (temp.length == 2) {
  272. let key = `${eachData.TypeCode}-${eachData.InfomationPointCode}`
  273. if (this.pointToRelationID[key]) {
  274. eachData.Id = this.pointToRelationID[key]
  275. }
  276. }
  277. let type = t.DataRuleType;
  278. updateParams.data.Content[0].EquipmentMark = eachData.EquipmentMark
  279. switch (type) {
  280. case '无需处理,直接使用':
  281. // otherParams = {
  282. // EquipmentMark: other.EquipmentMark
  283. // }
  284. // updateParams.data.Content[0].EquipmentMark = other.EquipmentMark
  285. break
  286. case '需自动单位转换':
  287. let DataRuleContent1 = JSON.stringify([
  288. {
  289. seq: 1,
  290. ruletype: 'type1',
  291. content: [
  292. {
  293. from: t.other.unit[0] + '-' + t.other.unit[1],
  294. to: this.unitObj[eachData.InfomationPointCode].unit
  295. }
  296. ]
  297. }
  298. ])
  299. eachData.DataRuleContent = DataRuleContent1;
  300. // otherParams = {
  301. // DataRuleContent: DataRuleContent1,
  302. // EquipmentMark: other.EquipmentMark
  303. // }
  304. // updateParams.data.Content[0].EquipmentMark = other.EquipmentMark
  305. break
  306. case '需按设置枚举转换':
  307. let DataRuleContent2 = t.other.pointArr.length
  308. ? JSON.stringify([{ seq: 1, ruletype: 'type2', content: t.other.pointArr }])
  309. : undefined
  310. // otherParams = {
  311. // EquipmentMark: other.EquipmentMark,
  312. // DataRuleContent: DataRuleContent2
  313. // }
  314. eachData.DataRuleContent = DataRuleContent2;
  315. // updateParams.data.Content[0].EquipmentMark = other.EquipmentMark
  316. break
  317. case '需按公式转换':
  318. let subRule = t.other.from
  319. ? {
  320. seq: 1,
  321. ruletype: 'type4',
  322. content: [
  323. {
  324. from: t.other.from,
  325. to: t.other.to
  326. }
  327. ]
  328. }
  329. : undefined
  330. let extractRule = {
  331. seq: 2,
  332. ruletype: 'type5',
  333. content: t.other.extract
  334. ? [
  335. {
  336. extract: 'number'
  337. }
  338. ]
  339. : []
  340. }
  341. let countRule = t.other.mark
  342. ? {
  343. seq: 3,
  344. ruletype: 'type6',
  345. content: [
  346. {
  347. calculationtype: t.other.mark,
  348. value: t.other.markValue
  349. }
  350. ]
  351. }
  352. : undefined
  353. let DataRuleContent3 = []
  354. if (subRule) {
  355. DataRuleContent3.push(subRule)
  356. }
  357. DataRuleContent3.push(extractRule)
  358. if (countRule) {
  359. DataRuleContent3.push(countRule)
  360. }
  361. DataRuleContent3 = DataRuleContent3.length ? JSON.stringify(DataRuleContent3) : undefined
  362. eachData.DataRuleContent = DataRuleContent3;
  363. // otherParams = {
  364. // EquipmentMark: other.EquipmentMark,
  365. // DataRuleContent: DataRuleContent3
  366. // }
  367. // updateParams.data.Content[0].EquipmentMark = other.EquipmentMark
  368. break
  369. case '需拆分处理':
  370. let SplitPoints = t.other.devArr.length ? t.other.devArr : undefined
  371. let DataRuleContent4 = undefined
  372. var enum5 = null
  373. if (t.other.tranfVal) {
  374. enum5 = { seq: 2, ruletype: 'type2', content: t.other.pointArr }
  375. } else {
  376. enum5 = { seq: 2, ruletype: 'type2', content: [] }
  377. }
  378. SplitPoints.forEach(ele => {
  379. let cutStr = {
  380. seq: 1,
  381. ruletype: 'type4',
  382. content: [
  383. {
  384. from: ele.SplitStart,
  385. to: ele.SplitEnd
  386. }
  387. ]
  388. }
  389. ele.DataRuleContent = JSON.stringify([cutStr, enum5])
  390. })
  391. eachData.SplitPoints = SplitPoints;
  392. // otherParams = {
  393. // SplitPoints: SplitPoints
  394. // }
  395. updateParams.data.Content[0].EquipmentMark = t.other.eqMark
  396. break
  397. }
  398. return eachData;
  399. })
  400. updatePoint(updateParams, res => { this.create(params) })
  401. },
  402. create(params) {
  403. batchCreate(params, res => {
  404. if (res.Result == 'success') {
  405. this.$message({
  406. message: '保存成功',
  407. type: 'success'
  408. })
  409. this.$emit('refresh')
  410. }
  411. })
  412. },
  413. errMsg() {
  414. this.$message({
  415. message: '有必填项未填',
  416. type: 'warning'
  417. })
  418. },
  419. handleChange(arr) {
  420. this.unitObj = this.infoDict[arr[3]]
  421. this.InfomationPoint = this.unitObj ? this.unitObj.infoPointName || '--' : '--'
  422. },
  423. handleItemChange(val, cb) {
  424. if (val.length == 3) {
  425. if (val[2] != 'null') {
  426. let params = { type: val[2] }
  427. getQueryProperty(params, res => {
  428. if (res.Result == 'success') {
  429. let data = res.Content
  430. let arr = data
  431. .filter(item => {
  432. return item.inputMode == 'L' || item.inputMode == 'M'
  433. })
  434. .map(item => {
  435. return {
  436. code: item.infoPointCode,
  437. name: item.infoPointName
  438. }
  439. })
  440. this.infoDict = {}
  441. data.forEach(item => {
  442. this.infoDict[item.infoPointCode] = item
  443. })
  444. this.optionObj = {}
  445. this.getOptionItem(this.options, val[2])
  446. if (arr.length) {
  447. this.optionObj.content = arr
  448. } else {
  449. this.optionObj.content = undefined
  450. }
  451. if (typeof cb == 'function') {
  452. cb()
  453. }
  454. }
  455. })
  456. }
  457. }
  458. },
  459. getOptionItem(arr, code) {
  460. for (var i = 0; i < arr.length; i++) {
  461. if (arr[i].code == code) {
  462. this.optionObj = arr[i]
  463. }
  464. if (arr[i].content && arr[i].content.length > 0) {
  465. this.getOptionItem(arr[i].content, code)
  466. }
  467. }
  468. },
  469. //缓存数据字典
  470. getDataDict(arr) {
  471. for (var i = 0; i < arr.length; i++) {
  472. this.dataDict[arr[i].code] = arr[i]
  473. if (arr[i].content && arr[i].content.length > 0) {
  474. this.getDataDict(arr[i].content)
  475. } else {
  476. this.$set(arr[i], 'content', [])
  477. }
  478. }
  479. },
  480. getEqAll() {
  481. let params = { format: true }
  482. getEquipmentAll(params, res => {
  483. if (res.Result == 'success') {
  484. this.options = res.Content
  485. this.getDataDict(this.options)
  486. }
  487. })
  488. },
  489. init() {
  490. //获取所有的设备
  491. // this.getEqAll()
  492. },
  493. //回显数值
  494. async showValue(val) {
  495. // await this.getEqAll()
  496. let length = val.RelationList.length
  497. let eqMark = this.editData.Point.EquipmentMark
  498. this.form.EquipmentMark = eqMark;
  499. if (length) {
  500. var data = val.RelationList[0]
  501. let dict = [data.SpecialtyCode, data.SystemCode, data.EquipmentTypeCode]
  502. //回显字典--并保存信息点->relationid map
  503. this.pointToRelationID = {}
  504. let tempArr = val.RelationList.map(t => {
  505. let eachData = [];
  506. if (t.TypeCode == 'Eq' || t.TypeCode == 'Ec' || t.TypeCode == 'Sp') {
  507. eachData = [t.TypeCode, t.EquipmentTypeCode, t.InfomationPointCode]
  508. if (this.pointToRelationID[`${t.TypeCode}-${t.EquipmentTypeCode}-${t.InfomationPointCode}`]) {
  509. return undefined
  510. }
  511. this.pointToRelationID[`${t.TypeCode}-${t.EquipmentTypeCode}-${t.InfomationPointCode}`] = t.Id
  512. } else if (t.TypeCode == 'Sy') {
  513. eachData = [t.TypeCode, t.SpecialtyCode, t.SystemCode, t.InfomationPointCode]
  514. if (this.pointToRelationID[`${t.TypeCode}-${t.SpecialtyCode}-${t.SystemCode}-${t.InfomationPointCode}`]) {
  515. return undefined
  516. }
  517. this.pointToRelationID[`${t.TypeCode}-${t.SpecialtyCode}-${t.SystemCode}-${t.InfomationPointCode}`] = t.Id
  518. } else {
  519. eachData = [t.TypeCode, t.InfomationPointCode]
  520. if (this.pointToRelationID[`${t.TypeCode}-${t.InfomationPointCode}`]) {
  521. return undefined
  522. }
  523. this.pointToRelationID[`${t.TypeCode}-${t.InfomationPointCode}`] = t.Id
  524. }
  525. return eachData;
  526. }).filter(item => item)
  527. this.$nextTick(() => {
  528. this.$refs.dictionaryCas.setCascaderVal(tempArr);
  529. })
  530. let typeTempList = []
  531. this.typeList = val.RelationList.map(t => {
  532. if (t.TypeCode == 'Eq' || t.TypeCode == 'Ec' || t.TypeCode == 'Sp') {
  533. t.name = `${t.Type}-${t.EquipmentType}-${t.InfomationPoint}`
  534. } else if (t.TypeCode == 'Sy') {
  535. t.name = `${t.Type}-${t.Specialty}-${t.System}-${t.InfomationPoint}`
  536. } else {
  537. t.name = `${t.Type}-${t.InfomationPoint}`
  538. }
  539. if (typeTempList.indexOf(t.name) > -1) {
  540. return undefined
  541. }
  542. typeTempList.push(t.name)
  543. return t;
  544. }).filter(item => item);
  545. this.form.DataRuleType = data.DataRuleType
  546. // this.handleItemChange(dict, () => {
  547. // this.unitObj = this.infoDict[data.InfomationPointCode]
  548. // this.InfomationPoint = this.unitObj.infoPointName || '--'
  549. // if (typeof this.unitObj.dataSource == 'string') {
  550. // if (this.unitObj.dataSource.length) {
  551. // this.ValueDescription = this.unitObj.dataSource
  552. // } else {
  553. // this.ValueDescription = '无信息点单位及值说明'
  554. // }
  555. // } else {
  556. // let str = ''
  557. // this.unitObj.dataSource.forEach(ele => {
  558. // str += ele.code + '.' + ele.name + ' '
  559. // })
  560. // this.ValueDescription = str
  561. // }
  562. // })
  563. if (length == 1) {
  564. let flag = data.DataRuleType
  565. var dataRules = null
  566. switch (flag) {
  567. case '无需处理,直接使用':
  568. this.noHandleShow = {
  569. EquipmentMark: eqMark
  570. }
  571. break
  572. case '需自动单位转换':
  573. dataRules = JSON.parse(data.DataRuleContent)
  574. let auto = dataRules[0].content[0].from.split('-')
  575. this.autoHandleShow = {
  576. EquipmentMark: eqMark,
  577. unit: auto
  578. }
  579. break
  580. case '需按设置枚举转换':
  581. dataRules = JSON.parse(data.DataRuleContent)
  582. let pointArr = dataRules[0].content
  583. this.enumHandleShow = {
  584. EquipmentMark: eqMark,
  585. pointArr: pointArr
  586. }
  587. break
  588. case '需按公式转换':
  589. var cut = null
  590. var count = null
  591. var extractArr = []
  592. if (data.DataRuleContent) {
  593. dataRules = JSON.parse(data.DataRuleContent)
  594. cut = dataRules[0].content[0]
  595. extractArr = dataRules[1].content
  596. count = dataRules[2].content[0]
  597. }
  598. this.formulaHandleShow = {
  599. EquipmentMark: eqMark,
  600. cut: cut,
  601. count: count,
  602. extractArr: extractArr
  603. }
  604. break
  605. case '需拆分处理':
  606. let dataRules = JSON.parse(data.DataRuleContent)
  607. let devArr = val.RelationList.map(ele => {
  608. let arr = JSON.parse(ele.DataRuleContent)
  609. return {
  610. EquipmentMark: ele.EquipmentMark,
  611. SplitStart: arr[0].content[0].from,
  612. SplitEnd: arr[0].content[0].to
  613. }
  614. })
  615. var pointArr = dataRules[1].content
  616. this.splitHandleShow = {
  617. eqMark: eqMark,
  618. EquipmentMark: data.EquipmentMark,
  619. pointArr: pointArr,
  620. devArr: devArr
  621. }
  622. break
  623. }
  624. } else {
  625. let dataRules = JSON.parse(data.DataRuleContent)
  626. let devArr = val.RelationList.map(ele => {
  627. let arr = JSON.parse(ele.DataRuleContent)
  628. return {
  629. EquipmentMark: ele.EquipmentMark,
  630. SplitStart: arr[0].content[0].from,
  631. SplitEnd: arr[0].content[0].to
  632. }
  633. })
  634. let pointArr = dataRules[1].content
  635. this.splitHandleShow = {
  636. eqMark: eqMark,
  637. EquipmentMark: data.EquipmentMark,
  638. pointArr: pointArr,
  639. devArr: devArr
  640. }
  641. }
  642. } else {
  643. this.noHandleShow = {
  644. EquipmentMark: eqMark
  645. }
  646. }
  647. this.noHandleShow.EquipmentMark = eqMark
  648. this.autoHandleShow.EquipmentMark = eqMark
  649. this.enumHandleShow.EquipmentMark = eqMark
  650. this.enumHandleShow.pointArr = this.enumHandleShow.pointArr ? this.enumHandleShow.pointArr : [{ from: '', to: '' }]
  651. this.formulaHandleShow.EquipmentMark = eqMark
  652. this.splitHandleShow.eqMark = eqMark
  653. this.splitHandleShow.devArr = this.splitHandleShow.devArr ? this.splitHandleShow.devArr : [{ EquipmentMark: '', SplitStart: 1, SplitEnd: 1 }]
  654. this.splitHandleShow.pointArr = this.splitHandleShow.pointArr ? this.splitHandleShow.pointArr : [{ from: '', to: '' }]
  655. },
  656. //处理函数
  657. delDataSource(val) {
  658. if (!val) {
  659. return '--'
  660. }
  661. val = JSON.parse(val)
  662. let str = ''
  663. val.forEach(el => {
  664. str += el.Code + '.' + el.Name + ' '
  665. })
  666. return str
  667. },
  668. //对应数据字典变化
  669. changeDictionaryCas({ val, labels, data }) {
  670. this.dictionaryData = val;
  671. this.dictionaryNames = labels || '';
  672. this.unitObj = data || {}
  673. if (this.typeList.length) {
  674. this.typeList = this.typeList.map(t => {
  675. if (labels.indexOf(t.name) < 0) {
  676. return undefined
  677. }
  678. return t;
  679. }).filter(item => item)
  680. let temp = this.typeList.map(t => {
  681. return t.name;
  682. })
  683. for (let i = 0; i < labels.length; i++) {
  684. if (temp.indexOf(labels[i]) < 0) {
  685. this.typeList.push({
  686. name: labels[i],
  687. DataRuleType: '无需处理,直接使用'
  688. })
  689. }
  690. }
  691. } else {
  692. this.typeList = labels.map(t => {
  693. return {
  694. name: t,
  695. DataRuleType: '无需处理,直接使用'
  696. }
  697. })
  698. }
  699. this.typeList = this.typeList.map((t, i) => {
  700. t.unitObj = {
  701. infoPointCode: data[val[i][val[i].length - 1]].InfoPointCode,
  702. infoPointName: data[val[i][val[i].length - 1]].InfoPointName,
  703. dataSource: data[val[i][val[i].length - 1]].DataSource || '',
  704. type: data[val[i][val[i].length - 1]].Type,
  705. unit: data[val[i][val[i].length - 1]].Unit
  706. }
  707. t.ValueDescription = this.delDataSource(data[val[i][val[i].length - 1]].DataSource)
  708. return t;
  709. })
  710. // this.infoDict = this.$refs.dictionaryCas.pointDataSource
  711. // this.InfomationPoint = this.unitObj.InfoPointName || ''
  712. // this.ValueDescription = this.delDataSource(this.unitObj.DataSource)
  713. }
  714. },
  715. mounted() {
  716. this.init()
  717. },
  718. watch: {
  719. editData: {
  720. immediate: true,
  721. handler(val) {
  722. this.showValue(val)
  723. }
  724. }
  725. }
  726. }
  727. </script>
  728. <style lang='scss' scoped>
  729. .point-box {
  730. border: 1px solid #ccc;
  731. display: flex;
  732. padding: 20px 0;
  733. max-height: 500px;
  734. overflow: auto;
  735. .left {
  736. width: 40%;
  737. ul li {
  738. display: flex;
  739. height: 40px;
  740. line-height: 40px;
  741. span:nth-of-type(1) {
  742. text-align: right;
  743. width: 120px;
  744. }
  745. span:nth-of-type(2) {
  746. width: calc(100% - 120px);
  747. overflow: hidden;
  748. text-overflow: ellipsis;
  749. white-space: nowrap;
  750. }
  751. }
  752. }
  753. .right {
  754. width: 60%;
  755. text-align: left;
  756. background: #fff;
  757. .form {
  758. width: 80%;
  759. .dict {
  760. .top {
  761. text-align: right;
  762. line-height: 33px;
  763. }
  764. .btm {
  765. margin-top: 5px;
  766. margin-left: 140px;
  767. }
  768. }
  769. }
  770. .btn-box {
  771. width: 80%;
  772. margin-top: 20px;
  773. text-align: center;
  774. }
  775. }
  776. }
  777. </style>