index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  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'>保存</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'])
  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. console.log('---------------')
  371. console.log(t.other)
  372. let SplitPoints = t.other.devArr.length ? t.other.devArr : undefined
  373. let DataRuleContent4 = undefined
  374. var enum5 = null
  375. if (t.other.tranfVal) {
  376. enum5 = { seq: 2, ruletype: 'type2', content: t.other.pointArr }
  377. } else {
  378. enum5 = { seq: 2, ruletype: 'type2', content: [] }
  379. }
  380. SplitPoints.forEach(ele => {
  381. let cutStr = {
  382. seq: 1,
  383. ruletype: 'type4',
  384. content: [
  385. {
  386. from: ele.SplitStart,
  387. to: ele.SplitEnd
  388. }
  389. ]
  390. }
  391. ele.DataRuleContent = JSON.stringify([cutStr, enum5])
  392. })
  393. console.log(SplitPoints)
  394. eachData.SplitPoints = SplitPoints;
  395. // otherParams = {
  396. // SplitPoints: SplitPoints
  397. // }
  398. updateParams.data.Content[0].EquipmentMark = t.other.eqMark
  399. break
  400. }
  401. return eachData;
  402. })
  403. updatePoint(updateParams, res => { this.create(params) })
  404. },
  405. create(params) {
  406. batchCreate(params, res => {
  407. if (res.Result == 'success') {
  408. this.$message({
  409. message: '保存成功',
  410. type: 'success'
  411. })
  412. this.$emit('refresh')
  413. }
  414. })
  415. },
  416. errMsg() {
  417. this.$message({
  418. message: '有必填项未填',
  419. type: 'warning'
  420. })
  421. },
  422. handleChange(arr) {
  423. this.unitObj = this.infoDict[arr[3]]
  424. this.InfomationPoint = this.unitObj ? this.unitObj.infoPointName || '--' : '--'
  425. },
  426. handleItemChange(val, cb) {
  427. if (val.length == 3) {
  428. if (val[2] != 'null') {
  429. let params = { type: val[2] }
  430. getQueryProperty(params, res => {
  431. if (res.Result == 'success') {
  432. let data = res.Content
  433. let arr = data
  434. .filter(item => {
  435. return item.inputMode == 'L' || item.inputMode == 'M'
  436. })
  437. .map(item => {
  438. return {
  439. code: item.infoPointCode,
  440. name: item.infoPointName
  441. }
  442. })
  443. this.infoDict = {}
  444. data.forEach(item => {
  445. this.infoDict[item.infoPointCode] = item
  446. })
  447. this.optionObj = {}
  448. this.getOptionItem(this.options, val[2])
  449. if (arr.length) {
  450. this.optionObj.content = arr
  451. } else {
  452. this.optionObj.content = undefined
  453. }
  454. if (typeof cb == 'function') {
  455. cb()
  456. }
  457. }
  458. })
  459. }
  460. }
  461. },
  462. getOptionItem(arr, code) {
  463. for (var i = 0; i < arr.length; i++) {
  464. if (arr[i].code == code) {
  465. this.optionObj = arr[i]
  466. }
  467. if (arr[i].content && arr[i].content.length > 0) {
  468. this.getOptionItem(arr[i].content, code)
  469. }
  470. }
  471. },
  472. //缓存数据字典
  473. getDataDict(arr) {
  474. for (var i = 0; i < arr.length; i++) {
  475. this.dataDict[arr[i].code] = arr[i]
  476. if (arr[i].content && arr[i].content.length > 0) {
  477. this.getDataDict(arr[i].content)
  478. } else {
  479. this.$set(arr[i], 'content', [])
  480. }
  481. }
  482. },
  483. getEqAll() {
  484. let params = { format: true }
  485. getEquipmentAll(params, res => {
  486. if (res.Result == 'success') {
  487. this.options = res.Content
  488. this.getDataDict(this.options)
  489. }
  490. })
  491. },
  492. init() {
  493. //获取所有的设备
  494. // this.getEqAll()
  495. },
  496. //回显数值
  497. async showValue(val) {
  498. // await this.getEqAll()
  499. let length = val.RelationList.length
  500. let eqMark = this.editData.Point.EquipmentMark
  501. this.form.EquipmentMark = eqMark;
  502. console.log('-------------')
  503. console.log(val)
  504. if (length) {
  505. var data = val.RelationList[0]
  506. let dict = [data.SpecialtyCode, data.SystemCode, data.EquipmentTypeCode]
  507. //回显字典--并保存信息点->relationid map
  508. this.pointToRelationID = {}
  509. let tempArr = val.RelationList.map(t => {
  510. let eachData = [];
  511. if (t.TypeCode == 'Eq' || t.TypeCode == 'Ec' || t.TypeCode == 'Sp') {
  512. eachData = [t.TypeCode, t.EquipmentTypeCode, t.InfomationPointCode]
  513. this.pointToRelationID[`${t.TypeCode}-${t.EquipmentTypeCode}-${t.InfomationPointCode}`] = t.Id
  514. } else if (t.TypeCode == 'Sy') {
  515. eachData = [t.TypeCode, t.SpecialtyCode, t.SystemCode, t.InfomationPointCode]
  516. this.pointToRelationID[`${t.TypeCode}-${t.SpecialtyCode}-${t.SystemCode}-${t.InfomationPointCode}`] = t.Id
  517. } else {
  518. eachData = [t.TypeCode, t.InfomationPointCode]
  519. this.pointToRelationID[`${t.TypeCode}-${t.InfomationPointCode}`] = t.Id
  520. }
  521. return eachData;
  522. })
  523. this.$nextTick(() => {
  524. this.$refs.dictionaryCas.setCascaderVal(tempArr);
  525. })
  526. this.typeList = val.RelationList.map(t => {
  527. if (t.TypeCode == 'Eq' || t.TypeCode == 'Ec' || t.TypeCode == 'Sp') {
  528. t.name = `${t.Type}-${t.EquipmentType}-${t.InfomationPoint}`
  529. } else if (t.TypeCode == 'Sy') {
  530. t.name = `${t.Type}-${t.Specialty}-${t.System}-${t.InfomationPoint}`
  531. } else {
  532. t.name = `${t.Type}-${t.InfomationPoint}`
  533. }
  534. return t;
  535. });
  536. this.form.DataRuleType = data.DataRuleType
  537. // this.handleItemChange(dict, () => {
  538. // this.unitObj = this.infoDict[data.InfomationPointCode]
  539. // this.InfomationPoint = this.unitObj.infoPointName || '--'
  540. // if (typeof this.unitObj.dataSource == 'string') {
  541. // if (this.unitObj.dataSource.length) {
  542. // this.ValueDescription = this.unitObj.dataSource
  543. // } else {
  544. // this.ValueDescription = '无信息点单位及值说明'
  545. // }
  546. // } else {
  547. // let str = ''
  548. // this.unitObj.dataSource.forEach(ele => {
  549. // str += ele.code + '.' + ele.name + ' '
  550. // })
  551. // this.ValueDescription = str
  552. // }
  553. // })
  554. if (length == 1) {
  555. let flag = data.DataRuleType
  556. var dataRules = null
  557. switch (flag) {
  558. case '无需处理,直接使用':
  559. this.noHandleShow = {
  560. EquipmentMark: eqMark
  561. }
  562. break
  563. case '需自动单位转换':
  564. dataRules = JSON.parse(data.DataRuleContent)
  565. let auto = dataRules[0].content[0].from.split('-')
  566. this.autoHandleShow = {
  567. EquipmentMark: eqMark,
  568. unit: auto
  569. }
  570. break
  571. case '需按设置枚举转换':
  572. dataRules = JSON.parse(data.DataRuleContent)
  573. let pointArr = dataRules[0].content
  574. this.enumHandleShow = {
  575. EquipmentMark: eqMark,
  576. pointArr: pointArr
  577. }
  578. break
  579. case '需按公式转换':
  580. var cut = null
  581. var count = null
  582. var extractArr = []
  583. if (data.DataRuleContent) {
  584. dataRules = JSON.parse(data.DataRuleContent)
  585. cut = dataRules[0].content[0]
  586. extractArr = dataRules[1].content
  587. count = dataRules[2].content[0]
  588. }
  589. this.formulaHandleShow = {
  590. EquipmentMark: eqMark,
  591. cut: cut,
  592. count: count,
  593. extractArr: extractArr
  594. }
  595. break
  596. case '需拆分处理':
  597. let dataRules = JSON.parse(data.DataRuleContent)
  598. let devArr = val.RelationList.map(ele => {
  599. let arr = JSON.parse(ele.DataRuleContent)
  600. return {
  601. EquipmentMark: ele.EquipmentMark,
  602. SplitStart: arr[0].content[0].from,
  603. SplitEnd: arr[0].content[0].to
  604. }
  605. })
  606. var pointArr = dataRules[1].content
  607. this.splitHandleShow = {
  608. eqMark: eqMark,
  609. EquipmentMark: data.EquipmentMark,
  610. pointArr: pointArr,
  611. devArr: devArr
  612. }
  613. break
  614. }
  615. } else {
  616. let dataRules = JSON.parse(data.DataRuleContent)
  617. let devArr = val.RelationList.map(ele => {
  618. let arr = JSON.parse(ele.DataRuleContent)
  619. return {
  620. EquipmentMark: ele.EquipmentMark,
  621. SplitStart: arr[0].content[0].from,
  622. SplitEnd: arr[0].content[0].to
  623. }
  624. })
  625. let pointArr = dataRules[1].content
  626. this.splitHandleShow = {
  627. eqMark: eqMark,
  628. EquipmentMark: data.EquipmentMark,
  629. pointArr: pointArr,
  630. devArr: devArr
  631. }
  632. }
  633. } else {
  634. this.noHandleShow = {
  635. EquipmentMark: eqMark
  636. }
  637. }
  638. this.noHandleShow.EquipmentMark = eqMark
  639. this.autoHandleShow.EquipmentMark = eqMark
  640. this.enumHandleShow.EquipmentMark = eqMark
  641. this.enumHandleShow.pointArr = this.enumHandleShow.pointArr ? this.enumHandleShow.pointArr : [{ from: '', to: '' }]
  642. this.formulaHandleShow.EquipmentMark = eqMark
  643. this.splitHandleShow.eqMark = eqMark
  644. this.splitHandleShow.devArr = this.splitHandleShow.devArr ? this.splitHandleShow.devArr : [{ EquipmentMark: '', SplitStart: 1, SplitEnd: 1 }]
  645. this.splitHandleShow.pointArr = this.splitHandleShow.pointArr ? this.splitHandleShow.pointArr : [{ from: '', to: '' }]
  646. },
  647. //处理函数
  648. delDataSource(val) {
  649. if (!val) {
  650. return '--'
  651. }
  652. val = JSON.parse(val)
  653. let str = ''
  654. val.forEach(el => {
  655. str += el.Code + '.' + el.Name + ' '
  656. })
  657. return str
  658. },
  659. //对应数据字典变化
  660. changeDictionaryCas({ val, labels, data }) {
  661. this.dictionaryData = val;
  662. this.dictionaryNames = labels || '';
  663. this.unitObj = data || {}
  664. if (this.typeList.length) {
  665. this.typeList = this.typeList.map(t => {
  666. if (labels.indexOf(t.name) < 0) {
  667. return undefined
  668. }
  669. return t;
  670. }).filter(item => item)
  671. let temp = this.typeList.map(t => {
  672. return t.name;
  673. })
  674. for (let i = 0; i < labels.length; i++) {
  675. if (temp.indexOf(labels[i]) < 0) {
  676. this.typeList.push({
  677. name: labels[i],
  678. DataRuleType: '无需处理,直接使用'
  679. })
  680. }
  681. }
  682. } else {
  683. this.typeList = labels.map(t => {
  684. return {
  685. name: t,
  686. DataRuleType: '无需处理,直接使用'
  687. }
  688. })
  689. }
  690. this.typeList = this.typeList.map((t, i) => {
  691. t.unitObj = {
  692. infoPointCode: data[val[i][val[i].length - 1]].InfoPointCode,
  693. infoPointName: data[val[i][val[i].length - 1]].InfoPointName,
  694. dataSource: data[val[i][val[i].length - 1]].DataSource || '',
  695. type: data[val[i][val[i].length - 1]].Type,
  696. unit: data[val[i][val[i].length - 1]].Unit
  697. }
  698. t.ValueDescription = this.delDataSource(data[val[i][val[i].length - 1]].DataSource)
  699. return t;
  700. })
  701. // this.infoDict = this.$refs.dictionaryCas.pointDataSource
  702. // this.InfomationPoint = this.unitObj.InfoPointName || ''
  703. // this.ValueDescription = this.delDataSource(this.unitObj.DataSource)
  704. }
  705. },
  706. mounted() {
  707. this.init()
  708. },
  709. watch: {
  710. editData: {
  711. immediate: true,
  712. handler(val) {
  713. this.showValue(val)
  714. }
  715. }
  716. }
  717. }
  718. </script>
  719. <style lang='scss' scoped>
  720. .point-box {
  721. border: 1px solid #ccc;
  722. display: flex;
  723. padding: 20px 0;
  724. max-height: 500px;
  725. overflow: auto;
  726. .left {
  727. width: 40%;
  728. ul li {
  729. display: flex;
  730. height: 40px;
  731. line-height: 40px;
  732. span:nth-of-type(1) {
  733. text-align: right;
  734. width: 120px;
  735. }
  736. span:nth-of-type(2) {
  737. width: calc(100% - 120px);
  738. overflow: hidden;
  739. text-overflow: ellipsis;
  740. white-space: nowrap;
  741. }
  742. }
  743. }
  744. .right {
  745. width: 60%;
  746. text-align: left;
  747. background: #fff;
  748. .form {
  749. width: 80%;
  750. .dict {
  751. .top {
  752. text-align: right;
  753. line-height: 33px;
  754. }
  755. .btm {
  756. margin-top: 5px;
  757. margin-left: 140px;
  758. }
  759. }
  760. }
  761. .btn-box {
  762. width: 80%;
  763. margin-top: 20px;
  764. text-align: center;
  765. }
  766. }
  767. }
  768. </style>