dialogAssets.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848
  1. <!--
  2. 上传文件的弹窗
  3. -->
  4. <template>
  5. <div v-if="dialog.addDevice">
  6. <el-dialog
  7. :title="title"
  8. :center="isCenter"
  9. :visible.sync="dialog.addDevice"
  10. :width="width"
  11. :fullscreen="isFull"
  12. >
  13. <div id="addDevice">
  14. <div v-show="!isCenter">
  15. <my-cascader ref="cascader" @change="changeCader"></my-cascader>
  16. </div>
  17. <div v-if="isCenter">
  18. <div>
  19. <div class="hanson-bar">
  20. <span>当前选择的设备族:{{ deviceType.facility }}</span>
  21. <div style="width:350px;float:right;overflow:hidden;">
  22. <span>增加</span>
  23. <el-input v-model="addNum" style="width:50px;" placeholder="增加个数" size="small"></el-input>
  24. <span>个{{ deviceType.facility }}</span>
  25. <el-button size="small" @click="addMain">增加</el-button>
  26. </div>
  27. <div
  28. style="width:200px;color:gray;float:right;padding-top:7px;font-size:10px;"
  29. >是否隐藏自动填充信息点:
  30. <el-tooltip :content="'' + (isWatch ? '隐藏' : '不隐藏')" placement="top">
  31. <el-switch
  32. @change="changeWatch"
  33. v-model="isWatch"
  34. active-color="#13ce66"
  35. inactive-color="gray"
  36. ></el-switch>
  37. </el-tooltip>
  38. </div>
  39. </div>
  40. <div v-show="main && main.length" id="myHandson" ref="myHandson"></div>
  41. </div>
  42. </div>
  43. </div>
  44. <div v-show="!isCenter" slot="footer" class="dialog-footer">
  45. <el-button>取 消</el-button>
  46. <el-button type="primary" @click="step(1)">下 一 步</el-button>
  47. </div>
  48. <span v-show="isCenter" slot="footer" class="dialog-footer">
  49. <el-button type="primary" @click="createAssets">创建资产</el-button>
  50. </span>
  51. </el-dialog>
  52. <qrcode :dialog="myDialog" :addBody="true" ref="qrcode"></qrcode>
  53. <firm
  54. :mess="{deviceId : deviceType.code}"
  55. ref="firm"
  56. @changeFirm="firmChange"
  57. :dialog="myDialog"
  58. ></firm>
  59. <supply-dialog @change="supplyChange" :id="id" ref="supply" :dialog="myDialog"></supply-dialog>
  60. <supplier-dialog ref="supplier" @changeSupplier="supplierChange" :dialog="myDialog"></supplier-dialog>
  61. <guarantee-dialog ref="guarantee" :id="id" @change="guaranteeChange" :dialog="myDialog"></guarantee-dialog>
  62. <upload-files-dialog
  63. ref="upload"
  64. @changeFile="fileChange"
  65. :keysArr="filesArr"
  66. :dialog="myDialog"
  67. ></upload-files-dialog>
  68. <upload-img-dialog @changeFile="imgChange" :keysArr="imgsArr" :dialog="myDialog"></upload-img-dialog>
  69. <maintainer-dialog @changeMaintainer="changeMaintainer" ref="maintainer" :dialog="myDialog"></maintainer-dialog>
  70. <insurer-dialog @changeInsurer="changeInsurer" ref="insurer" :dialog="myDialog"></insurer-dialog>
  71. <pic-dialog :dialog="myDialog" :keysArr="picsArr" @change="changePics"></pic-dialog>
  72. </div>
  73. </template>
  74. <script>
  75. import myCascader from "@/components/lib/cascaders/assets";
  76. import hansonTable from "@/components/dialogHanson/addDevice";
  77. import tools from "@/utils/scan/tools";
  78. import qrcode from "@/components/ledger/lib/qrcode";
  79. import firm from "@/components/dialogs/list/firm";
  80. import supplyDialog from "@/components/dialogs/list/supplyDialog";
  81. import supplierDialog from "@/components/dialogs/list/supplierDialog";
  82. import maintainerDialog from "@/components/dialogs/list/maintainerDialog";
  83. import insurerDialog from "@/components/dialogs/list/insurerDialog";
  84. import guaranteeDialog from "@/components/dialogs/list/guaranteeDialog";
  85. import uploadFilesDialog from "@/components/dialogs/list/filesDialog";
  86. import uploadImgDialog from "@/components/dialogs/list/uploadImgDialog";
  87. import picDialog from "@/components/dialogs/list/picDialog"
  88. //下拉插件
  89. import "@/assets/js/chosen.jquery.min";
  90. import "@/assets/js/handsontable-chosen-editor";
  91. import text from "@/utils/handsontable/mainText"
  92. import showTools from "@/utils/handsontable/notShow"
  93. import uuid from "@/utils/uuid";
  94. import { mapGetters, mapActions } from "vuex";
  95. import { getTableHeader, createProperty, getSpaceFloor, createAssetsList } from "@/api/scan/request";
  96. let table = function (num) {
  97. let main = []
  98. for (let i = 0; i < num; i++) {
  99. main.push({})
  100. }
  101. return main
  102. }
  103. export default {
  104. components: {
  105. myCascader,
  106. hansonTable,
  107. qrcode, //二维码页面
  108. firm, //
  109. supplyDialog,
  110. supplierDialog,
  111. guaranteeDialog,
  112. uploadFilesDialog,
  113. maintainerDialog,
  114. insurerDialog,
  115. uploadImgDialog,
  116. picDialog
  117. },
  118. props: {
  119. dialog: {
  120. type: Object,
  121. default: function () {
  122. return {
  123. addDevice: false
  124. };
  125. }
  126. },
  127. assetType: {
  128. type: Array,
  129. default: function () {
  130. return []
  131. }
  132. }
  133. },
  134. data() {
  135. return {
  136. width: "30%",
  137. isFull: false,//dialog是否为全屏
  138. title: "确定新增资产的类型",
  139. isCenter: false,
  140. deviceType: {},
  141. main: table(1),
  142. mess: {},
  143. headers: null,
  144. page: {
  145. size: 50,
  146. sizes: [10, 30, 50, 100, 150, 200],
  147. total: 400,
  148. currentPage: 1
  149. },
  150. id: 0,
  151. myDialog: {
  152. qrcode: false, //二维码弹窗
  153. firm: false, //厂商弹窗
  154. supply: false, //选择供应合同
  155. supplier: false, //供应商选择
  156. guarantee: false, //选择保单
  157. maintainer: false, //选择维修商
  158. insurer: false, //选择保险公司
  159. uploadFiles: false,//上传文件
  160. uploadImgs: false,//上传单个图片
  161. pic: false, //多个图片
  162. },
  163. addNum: 1,//增加个数
  164. row: null,//被修改的row
  165. filesArr: [],//保存临时的文件key
  166. messKey: null,
  167. imgsArr: [],//临时保存的图片key数组
  168. picsArr: [],//临时设备图片keys数组
  169. param: {
  170. ProjId: "",
  171. secret: ""
  172. },
  173. floorData: [],
  174. isWatch: true,
  175. ajaxResult: true
  176. };
  177. },
  178. computed: {
  179. ...mapGetters("layout", [
  180. "projectId",
  181. "secret",
  182. "userId"
  183. ])
  184. },
  185. created() {
  186. this.param.ProjId = this.projectId
  187. this.param.secret = this.secret
  188. // this.getFloorData()
  189. },
  190. mounted() {
  191. },
  192. methods: {
  193. //设置默认选中数据
  194. setValue() {
  195. this.$nextTick(_ => {
  196. this.$refs.cascader.setValue(this.assetType)
  197. })
  198. },
  199. //获取楼层数据
  200. // getFloorData() { // 物理世界 已无接口
  201. // getSpaceFloor(this.param).then(res => {
  202. // if (res.data.Result == 'success') {
  203. // let data = this.changeArr(res.data.Content), floorData = []
  204. // data.map(item => {
  205. // if (!!item.children) {
  206. // item.children.unshift({
  207. // value: '',
  208. // label: "未明确楼层的设备"
  209. // })
  210. // }
  211. // return item
  212. // })
  213. // data.map(item => {
  214. // if (!!item.children && item.children.length) {
  215. // item.children.map(child => {
  216. // floorData.push({
  217. // Code: item.value + "-" + child.value,
  218. // Name: item.label + "-" + child.label
  219. // })
  220. // })
  221. // }
  222. // })
  223. // this.floorData = floorData
  224. // // this.options = data
  225. // } else {
  226. // this.$message.error(res.data.ResultMsg)
  227. // }
  228. // }).catch(() => {
  229. // this.$message.error("请求出错")
  230. // })
  231. // },
  232. //将数组转换成optiosn格式
  233. changeArr(arr) {
  234. return arr.map(item => {
  235. if (item.floors && item.floors.length) {
  236. return {
  237. value: item.id,
  238. label: item.infos.BuildLocalName,
  239. children: item.floors.map(i => {
  240. return {
  241. value: i.id,
  242. label: i.infos.FloorLocalName || "未知",
  243. }
  244. })
  245. }
  246. } else {
  247. return {
  248. value: item.id,
  249. label: item.infos.BuildLocalName,
  250. children: null,
  251. isChilren: 1,
  252. }
  253. }
  254. })
  255. },
  256. //增加个数
  257. addMain() {
  258. for (let i = 0; i < this.addNum; i++) {
  259. this.main.push({})
  260. }
  261. if (!!this.hot) {
  262. this.hot.destroy()
  263. }
  264. this.initHot()
  265. },
  266. //下一步
  267. step(val) {
  268. if (!!val) {
  269. this.isFull = true
  270. this.isCenter = true
  271. this.title = "添加资产"
  272. this.getData()
  273. } else {
  274. this.isFull = false
  275. this.isCenter = false
  276. }
  277. },
  278. //修改设备类型
  279. changeCader(val) {
  280. this.deviceType = val
  281. },
  282. //获取header的mess
  283. getHeader(mess) {
  284. this.mess = mess;
  285. },
  286. //获取主体内容
  287. getMain(floorMess) {
  288. },
  289. //获取表头
  290. getData() {
  291. this.main = table(1)
  292. getTableHeader({
  293. code: this.deviceType.code,
  294. ProjId: this.projectId
  295. }).then(res => {
  296. this.headers = res.data.Content;
  297. if (!!this.hot) {
  298. this.hot.destroy();
  299. this.hot = null;
  300. }
  301. let data = tools.getItem(this.deviceType.code)
  302. if (!!data) {
  303. this.main = data
  304. }
  305. this.initHot();
  306. });
  307. },
  308. changeWatch() {
  309. this.getData()
  310. },
  311. //撤回
  312. undo() {
  313. this.hot.undo();
  314. },
  315. //刷新
  316. reset() {
  317. this.getData();
  318. },
  319. //添加设备
  320. addDevice() {
  321. },
  322. //创建资产
  323. createAssets() {
  324. let data = []
  325. let copyData = tools.copyArr(this.main)
  326. let falg = false
  327. copyData.map(item => {
  328. if (!!item.infos) {
  329. if (item.infos.EquipLocalName) {
  330. item.family = this.deviceType.code
  331. data.push(item)
  332. } else {
  333. falg = true
  334. }
  335. }
  336. })
  337. if (falg) {
  338. this.$message.error("存在资产的本地名称为空,请检查")
  339. return
  340. }
  341. let params = []
  342. data.map(item => {
  343. if (!!item.infos) {
  344. let one = {}
  345. if (!!item.flowBuild) {
  346. one.BuildId = item.flowBuild.split("-")[0]
  347. one.FloorId = item.flowBuild.split("-")[1] || null
  348. }
  349. one.Family = this.deviceType.code
  350. one.FamilyName = this.deviceType.facility
  351. one.Infos = item.infos
  352. one.FmId = "Pe" + uuid(32, 16)
  353. one.ProjId = this.projectId
  354. one.FmName = item.infos.EquipLocalName || ""
  355. one.X = 0
  356. one.Y = 0
  357. params.push(one)
  358. }
  359. })
  360. params.map(item => {
  361. for (let k in item.Infos) {
  362. if (item.Infos[k] == "") {
  363. item.Infos[k] = null
  364. }
  365. }
  366. })
  367. if (params.length) {
  368. this.createJson(params)
  369. } else {
  370. this.$message.error("信息点不能为空")
  371. }
  372. },
  373. //新建资产请求
  374. async createJson(data) {
  375. data.map(item => {
  376. if (!!item.Infos.dpSupplierId) {
  377. item.Infos.dpSupplierId = item.Infos.dpSupplierId.split("-")[0]
  378. }
  379. if (!!item.Infos.dpManufacturerId) {
  380. item.Infos.dpManufacturerId = item.Infos.dpManufacturerId.split("-")[0]
  381. }
  382. if (!!item.Infos.dpInsurerId) {
  383. item.Infos.dpInsurerId = item.Infos.dpInsurerId.split("-")[0]
  384. }
  385. if (!!item.Infos.dpMaintainerId) {
  386. item.Infos.dpMaintainerId = item.Infos.dpMaintainerId.split("-")[0]
  387. }
  388. if (!!item.Infos.dpSpecificationId) {
  389. item.Infos.dpSpecificationId = item.Infos.dpSpecificationId.split("-")[0]
  390. }
  391. for (let k in item.Infos) {
  392. if (item.Infos[k] == "") {
  393. item.Infos[k] = null
  394. }
  395. }
  396. return item
  397. })
  398. this.ajaxResult = true
  399. let param = {
  400. FmList: data,
  401. ProjId: this.projectId,
  402. UserId: this.userId
  403. }
  404. await this.createAssetId(param)
  405. },
  406. async createAssetId(param) {
  407. await createAssetsList(param, res => {
  408. console.log(res)
  409. if (res.Result != "success") {
  410. this.$message.error("请求错误")
  411. } else {
  412. tools.removeItem(this.deviceType.code)
  413. this.$emit("close", this.deviceType)
  414. this.dialog.addDevice = false
  415. }
  416. })
  417. },
  418. /**
  419. * 表头文案处理函数
  420. * @param list header数组数据
  421. *
  422. * @return 处理好的文案
  423. */
  424. delHeader(list) {
  425. let arr = tools.copyArr(list)
  426. // 如果不是只读状态,添加四大厂商选择
  427. arr = showTools.arrToArr(arr)
  428. let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "X", "L", "L1", "L2", "F1", "F2", "M"]
  429. readArr.push("Own")
  430. let data = showTools.changeHeader(arr, readArr, false, this.isWatch, false, true)
  431. data.unshift("所属建筑楼层");
  432. console.log(data, "data")
  433. return data;
  434. },
  435. /**
  436. * 表头数据处理函数
  437. * @param list header数组数据
  438. *
  439. * @return 处理好的数据格式
  440. */
  441. getType(list) {
  442. let arr = tools.copyArr(list)
  443. // 如果不是只读状态,添加四大厂商选择
  444. if (!this.onlyRead) {
  445. arr = showTools.arrToArr(arr)
  446. }
  447. let data = showTools.showTypes(arr, false, this.isWatch, false, true)
  448. data.unshift(
  449. {
  450. data: "flowBuild",
  451. renderer: tools.customDropdownRenderer,
  452. editor: "chosen",
  453. chosenOptions: {
  454. data: this.floorData
  455. }
  456. }
  457. );
  458. console.log("type", data)
  459. return data;
  460. },
  461. //初始化插件
  462. initHot() {
  463. var container = document.getElementById("myHandson");
  464. let winHeight = document.documentElement.clientHeight;
  465. this.hot = new Handsontable(container, {
  466. data: this.main,
  467. colHeaders: this.delHeader(this.headers), //表头文案
  468. columns: this.getType(this.headers), //数据显示格式
  469. filters: true,
  470. rowHeaders: true,
  471. height: winHeight - 100 - 50 - 60,
  472. columnSorting: true, //添加排序
  473. sortIndicator: true, //添加排序
  474. renderAllRows: true,
  475. autoColumnSize: true,
  476. language: "zh-CN",
  477. maxRows: this.main.length,
  478. manualColumnResize: true,
  479. manualColumnMove: true,
  480. dropdownMenu: [
  481. "filter_by_condition",
  482. "filter_by_value",
  483. "filter_action_bar"
  484. ],
  485. contextMenu: this.onlyRead ? false : {
  486. items: {
  487. remove_row: {
  488. name: "删除该资产"
  489. }
  490. }
  491. },
  492. afterChange: this.tdChange, //修改后
  493. afterFilter: this.trimmedRows, //排序前
  494. afterRemoveRow: this.romoveFm, //右键删除
  495. afterOnCellMouseDown: this.eventClick //鼠标点击
  496. });
  497. let pro = document.getElementById("hot-display-license-info");
  498. if (!!pro) {
  499. pro.parentNode.removeChild(pro);
  500. }
  501. this.isLoading = false;
  502. },
  503. tdChange() {
  504. tools.setItem(this.deviceType.code, this.main)
  505. },
  506. //表格中的点击
  507. eventClick(el, rowArr) {
  508. //点击的是表头
  509. if (rowArr.row < 0) {
  510. return;
  511. }
  512. let filter = this.filtersArr;
  513. //被筛选过后的数组
  514. let trimmedArr = this.trimmedRows();
  515. //是否启用了排序
  516. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  517. if (trimmedArr.length && isSort) {
  518. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  519. .__arrayMap;
  520. let infos = this.main[trimmedArr[sortArr[rowArr.row]]];
  521. this.getInfors(infos, sortArr[rowArr.row]);
  522. } else if (isSort) {
  523. //排序后的数组
  524. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  525. let infos = this.main[sortArr[rowArr.row]];
  526. this.getInfors(infos, sortArr[rowArr.row]);
  527. } else if (trimmedArr.length) {
  528. let infos = this.main[trimmedArr[rowArr.row]];
  529. this.getInfors(infos, trimmedArr[rowArr.row]);
  530. } else {
  531. let infos = this.main[rowArr.row];
  532. this.getInfors(infos, rowArr);
  533. }
  534. },
  535. getInfors(infos, row) {
  536. //其他的开始判断
  537. let val = this.hot.colToProp(row.col);
  538. if (val == "infos.EquipQRCode") {
  539. this.myDialog.qrcode = true;
  540. this.$refs.qrcode.getCanvas(1111);
  541. }
  542. if (val == "linkSystem") {
  543. this.systemList = this.main[row.row].linkSystem || []
  544. this.dialog.systemType = true
  545. }
  546. if (val == "infos.dpManufacturerId") {
  547. this.myDialog.firm = true;
  548. }
  549. if (val == "infos.SupplierContractID") {
  550. let falg = null
  551. if (!!this.main[row.row].infos) {
  552. if (!!this.main[row.row].infos) {
  553. falg = this.main[row.row].infos.dpSupplierId.split("-")[0]
  554. }
  555. }
  556. if (!!falg) {
  557. this.id = falg
  558. this.myDialog.supply = true;
  559. } else {
  560. this.$message("请先选择供应商")
  561. }
  562. }
  563. if (val == "infos.InsuranceNum") {
  564. //选择保单
  565. let falg = null
  566. if (!!this.main[row.row].infos) {
  567. if (!!this.main[row.row].infos) {
  568. falg = this.main[row.row].infos.dpInsurerId.split("-")[0]
  569. }
  570. }
  571. if (!!falg) {
  572. this.id = falg
  573. this.myDialog.guarantee = true;
  574. } else {
  575. this.$message("请先选择保险商")
  576. }
  577. }
  578. if (val == "infos.InsuranceFile" || val == "infos.Archive") {
  579. this.filesArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
  580. this.myDialog.uploadFiles = true
  581. }
  582. if (
  583. val == "infos.InstallPic" ||
  584. val == "infos.InstallDrawing" ||
  585. val == "infos.Nameplate" ||
  586. val == "infos.Drawing"
  587. ) {
  588. if (val == "infos.Nameplate") {
  589. this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]].key] : []) : []
  590. } else {
  591. this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
  592. }
  593. this.myDialog.uploadImgs = true
  594. }
  595. if (val == "infos.Pic") {
  596. this.picsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
  597. this.myDialog.pic = true
  598. }
  599. if (
  600. val == "infos.Supplier"
  601. ) {
  602. this.myDialog.supplier = true;
  603. }
  604. if (
  605. val == "infos.dpSupplierId"
  606. ) {
  607. this.myDialog.supplier = true;
  608. }
  609. if (val == "infos.dpMaintainerId"
  610. ) {
  611. this.myDialog.maintainer = true;
  612. }
  613. if (
  614. val == "infos.dpInsurerId"
  615. ) {
  616. this.myDialog.insurer = true;
  617. }
  618. if (val == "infos.maintainer") {
  619. this.myDialog.maintainer = true;
  620. }
  621. if (
  622. val == "infos.Insurer" ||
  623. val == "infos.InsurerContactor") {
  624. this.myDialog.insurer = true;
  625. }
  626. this.row = row.row
  627. this.messKey = val
  628. console.log(val, row);
  629. },
  630. //获取被筛选掉的行号
  631. trimmedRows() {
  632. // var plugin = hot.getPlugin('trimRows').trimmedRows;//获取被筛选掉的行号
  633. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  634. let dataLength = this.main.length;
  635. let dataArr = new Array();
  636. for (let i = 0; i < dataLength; i++) {
  637. dataArr.push(i);
  638. }
  639. if (plugin.length <= 0) {
  640. dataArr = undefined;
  641. } else {
  642. dataArr = this.array_diff(dataArr, plugin);
  643. }
  644. return dataArr || [];
  645. // var DataArray = new Array();
  646. // for (var i = 0; i < plugin.length; i++) {
  647. // // 通过行号获取数据
  648. // DataArray.push(this.hot.getSourceDataAtRow(plugin[i]));
  649. // }
  650. },
  651. //判断是否为空行
  652. isEmptyRow(instance, row) {
  653. var rowData = instance.countRows();
  654. for (var i = 0, ilen = rowData.length; i < ilen; i++) {
  655. if (rowData[i] !== null) {
  656. return false;
  657. }
  658. }
  659. return true;
  660. },
  661. //选择型号修改
  662. firmChange(data) {
  663. for (let key in data) {
  664. // this.utilToKey(key, "brand", data, "Brand")
  665. // this.utilToKey(key, "name", data, "Specification")
  666. // this.utilToKey(key, "venderName", data, "manufacturer")
  667. if (key == "venderId") {
  668. data[key] = data[key] + "-" + data.name + "/" + data.brand
  669. this.utilToKey(key, "venderId", data, "dpManufacturerId")
  670. }
  671. this.utilToKey(key, "specificationId", data, "dpSpecificationId")
  672. }
  673. tools.setItem(this.deviceType.code, this.main)
  674. },
  675. //如果选择供应商之后
  676. supplierChange(data) {
  677. for (let key in data) {
  678. // this.utilToKey(key, "name", data, "Supplier")
  679. // this.utilToKey(key, "email", data, "SupplierEmail")
  680. // this.utilToKey(key, "website", data, "SupplierWeb")
  681. // this.utilToKey(key, "phone", data, "SupplierPhone")
  682. // this.utilToKey(key, "fox", data, "SupplierFax")
  683. // this.utilToKey(key, "man", data, "SupplierContactor")
  684. if (key == "venderId") {
  685. data[key] = data[key] + "-" + data.name
  686. console.log(data)
  687. this.utilToKey(key, "venderId", data, "dpSupplierId")
  688. }
  689. // this.utilToKey(key, "specificationId", data, "dpSpecificationId")
  690. }
  691. tools.setItem(this.deviceType.code, this.main)
  692. },
  693. //供应商合同
  694. supplyChange(data) {
  695. let changeData = { id: data }
  696. this.utilToKey("id", "id", changeData, "SupplierContractID")
  697. tools.setItem(this.deviceType.code, this.main)
  698. },
  699. //保险合同
  700. guaranteeChange(data) {
  701. for (let key in data) {
  702. this.utilToKey(key, "insuranceNo", data, "InsuranceNum")
  703. if (key == "contractFile") {
  704. if (!!data[key]) {
  705. data[key] = [data[key]]
  706. }
  707. }
  708. this.utilToKey(key, "contractFile", data, "InsuranceFile")
  709. }
  710. tools.setItem(this.deviceType.code, this.main)
  711. },
  712. //保险商变更
  713. changeInsurer(data) {
  714. for (let key in data) {
  715. // this.utilToKey(key, "name", data, "Insurer")
  716. // this.utilToKey(key, "email", data, "InsurerEmail")
  717. // this.utilToKey(key, "website", data, "InsurerWeb")
  718. // this.utilToKey(key, "phone", data, "InsurerFax")
  719. // this.utilToKey(key, "man", data, "InsurerContactor")
  720. if (key == "venderId") {
  721. data[key] = data[key] + "-" + data.name
  722. this.utilToKey(key, "venderId", data, "dpInsurerId")
  723. }
  724. }
  725. tools.setItem(this.deviceType.code, this.main)
  726. },
  727. //维修商变更
  728. changeMaintainer(data) {
  729. for (let key in data) {
  730. // this.utilToKey(key, "name", data, "maintainer")
  731. // this.utilToKey(key, "email", data, "MaintainerEmail")
  732. // this.utilToKey(key, "website", data, "MaintainerWeb")
  733. // this.utilToKey(key, "phone", data, "MaintainerPhone")
  734. // this.utilToKey(key, "fox", data, "MaintainerFax")
  735. // this.utilToKey(key, "man", data, "MaintainerContactor")
  736. if (key == "venderId") {
  737. data[key] = data[key] + "-" + data.name
  738. this.utilToKey(key, "venderId", data, "dpMaintainerId")
  739. }
  740. }
  741. tools.setItem(this.deviceType.code, this.main)
  742. },
  743. utilToKey(key, name, data, messName) {
  744. if (key == name) {
  745. this.setDataToMain(data[key], messName, this.row)
  746. }
  747. },
  748. //上传文件弹窗触发事件
  749. fileChange(keys) {
  750. this.setDataToMain(keys[0], this.messKey.split("."), this.row)
  751. tools.setItem(this.deviceType.code, this.main)
  752. },
  753. //上传图片弹窗触发事件
  754. imgChange(keys) {
  755. console.log(keys, "keys", this.messKey.split("."), this.row, '22222222222222')
  756. this.setDataToMain(keys[0], this.messKey.split("."), this.row)
  757. tools.setItem(this.deviceType.code, this.main)
  758. },
  759. //设备图片弹窗改变事件
  760. changePics(keys) {
  761. console.log(keys, "keys", this.messKey.split("."), this.row, '22222222222222')
  762. this.setDataToMain(keys, this.messKey.split("."), this.row)
  763. tools.setItem(this.deviceType.code, this.main)
  764. },
  765. //判断是否有值,有值赋值
  766. setDataToMain(data, key, row) {
  767. if (!!data && data != '--') {
  768. if (!!this.main[row].infos) {
  769. //铭牌照片特殊处理
  770. this.main[row].infos[key] = data
  771. } else {
  772. this.main[row].infos = {}
  773. this.main[row].infos[key] = data
  774. }
  775. } else {
  776. this.main[row].infos[key] = ''
  777. }
  778. }
  779. },
  780. watch: {
  781. dialog: {
  782. deep: true,
  783. handler: function () {
  784. if (this.dialog.addDevice) {
  785. this.setValue()
  786. }
  787. }
  788. }
  789. }
  790. };
  791. </script>
  792. <style lang="less" scoped>
  793. #addDevice {
  794. overflow: hidden;
  795. }
  796. </style>