dialogAssets.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  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. methods: {
  192. //设置默认选中数据
  193. setValue() {
  194. this.$nextTick(_ => {
  195. this.$refs.cascader.setValue(this.assetType)
  196. })
  197. },
  198. //获取楼层数据
  199. getFloorData() {
  200. getSpaceFloor(this.param).then(res => {
  201. if (res.data.Result == 'success') {
  202. let data = this.changeArr(res.data.Content), floorData = []
  203. data.map(item => {
  204. if (!!item.children) {
  205. item.children.unshift({
  206. value: '',
  207. label: "未明确楼层的设备"
  208. })
  209. }
  210. return item
  211. })
  212. data.map(item => {
  213. if (!!item.children && item.children.length) {
  214. item.children.map(child => {
  215. floorData.push({
  216. Code: item.value + "-" + child.value,
  217. Name: item.label + "-" + child.label
  218. })
  219. })
  220. }
  221. })
  222. this.floorData = floorData
  223. // this.options = data
  224. } else {
  225. this.$message.error(res.data.ResultMsg)
  226. }
  227. }).catch(() => {
  228. this.$message.error("请求出错")
  229. })
  230. },
  231. //将数组转换成optiosn格式
  232. changeArr(arr) {
  233. return arr.map(item => {
  234. if (item.floors && item.floors.length) {
  235. return {
  236. value: item.id,
  237. label: item.infos.BuildLocalName,
  238. children: item.floors.map(i => {
  239. return {
  240. value: i.id,
  241. label: i.infos.FloorLocalName || "未知",
  242. }
  243. })
  244. }
  245. } else {
  246. return {
  247. value: item.id,
  248. label: item.infos.BuildLocalName,
  249. children: null,
  250. isChilren: 1,
  251. }
  252. }
  253. })
  254. },
  255. //增加个数
  256. addMain() {
  257. for (let i = 0; i < this.addNum; i++) {
  258. this.main.push({})
  259. }
  260. if (!!this.hot) {
  261. this.hot.destroy()
  262. }
  263. this.initHot()
  264. },
  265. //下一步
  266. step(val) {
  267. if (!!val) {
  268. this.isFull = true
  269. this.isCenter = true
  270. this.title = "添加资产"
  271. this.getData()
  272. } else {
  273. this.isFull = false
  274. this.isCenter = false
  275. }
  276. },
  277. //修改设备类型
  278. changeCader(val) {
  279. this.deviceType = val
  280. },
  281. //获取header的mess
  282. getHeader(mess) {
  283. this.mess = mess;
  284. },
  285. //获取主体内容
  286. getMain(floorMess) {
  287. },
  288. //获取表头
  289. getData() {
  290. this.main = table(1)
  291. getTableHeader({
  292. code: this.deviceType.code,
  293. ProjId: this.projectId
  294. }).then(res => {
  295. this.headers = res.data.Content;
  296. if (!!this.hot) {
  297. this.hot.destroy();
  298. this.hot = null;
  299. }
  300. let data = tools.getItem(this.deviceType.code)
  301. if (!!data) {
  302. this.main = data
  303. }
  304. this.initHot();
  305. });
  306. },
  307. changeWatch() {
  308. this.getData()
  309. },
  310. //撤回
  311. undo() {
  312. this.hot.undo();
  313. },
  314. //刷新
  315. reset() {
  316. this.getData();
  317. },
  318. //添加设备
  319. addDevice() {
  320. },
  321. //创建资产
  322. createAssets() {
  323. let data = []
  324. let copyData = tools.copyArr(this.main)
  325. let falg = false
  326. copyData.map(item => {
  327. if (!!item.infos) {
  328. if (item.infos.EquipLocalName) {
  329. item.family = this.deviceType.code
  330. data.push(item)
  331. } else {
  332. falg = true
  333. }
  334. }
  335. })
  336. if (falg) {
  337. this.$message.error("存在资产的本地名称为空,请检查")
  338. return
  339. }
  340. let params = []
  341. data.map(item => {
  342. if (!!item.infos) {
  343. let one = {}
  344. if (!!item.flowBuild) {
  345. one.BuildId = item.flowBuild.split("-")[0]
  346. one.FloorId = item.flowBuild.split("-")[1] || null
  347. }
  348. one.Family = this.deviceType.code
  349. one.FamilyName = this.deviceType.facility
  350. one.Infos = item.infos
  351. one.FmId = "Pe" + uuid(32, 16)
  352. one.ProjId = this.projectId
  353. one.FmName = item.infos.EquipLocalName || ""
  354. one.X = 0
  355. one.Y = 0
  356. params.push(one)
  357. }
  358. })
  359. params.map(item => {
  360. for (let k in item.Infos) {
  361. if (item.Infos[k] == "") {
  362. item.Infos[k] = null
  363. }
  364. }
  365. })
  366. if (params.length) {
  367. this.createJson(params)
  368. } else {
  369. this.$message.error("信息点不能为空")
  370. }
  371. },
  372. //新建资产请求
  373. async createJson(data) {
  374. data.map(item => {
  375. if (!!item.Infos.DPSupplierID) {
  376. item.Infos.DPSupplierID = item.Infos.DPSupplierID.split("-")[0]
  377. }
  378. if (!!item.Infos.DPManufacturerID) {
  379. item.Infos.DPManufacturerID = item.Infos.DPManufacturerID.split("-")[0]
  380. }
  381. if (!!item.Infos.DPInsurerID) {
  382. item.Infos.DPInsurerID = item.Infos.DPInsurerID.split("-")[0]
  383. }
  384. if (!!item.Infos.DPMaintainerID) {
  385. item.Infos.DPMaintainerID = item.Infos.DPMaintainerID.split("-")[0]
  386. }
  387. if (!!item.Infos.DPSpecificationID) {
  388. item.Infos.DPSpecificationID = item.Infos.DPSpecificationID.split("-")[0]
  389. }
  390. for (let k in item.Infos) {
  391. if (item.Infos[k] == "") {
  392. item.Infos[k] = null
  393. }
  394. }
  395. return item
  396. })
  397. this.ajaxResult = true
  398. let param = {
  399. FmList: data,
  400. ProjId: this.projectId,
  401. UserId: this.userId
  402. }
  403. await this.createAssetId(param)
  404. },
  405. async createAssetId(param) {
  406. await createAssetsList(param, res => {
  407. console.log(res)
  408. if (res.Result != "success") {
  409. this.$message.error("请求错误")
  410. } else {
  411. tools.removeItem(this.deviceType.code)
  412. this.$emit("close", this.deviceType)
  413. this.dialog.addDevice = false
  414. }
  415. })
  416. },
  417. /**
  418. * 表头文案处理函数
  419. * @param list header数组数据
  420. *
  421. * @return 处理好的文案
  422. */
  423. delHeader(list) {
  424. let arr = tools.copyArr(list)
  425. // 如果不是只读状态,添加四大厂商选择
  426. arr = showTools.arrToArr(arr)
  427. let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "X", "L", "L1", "L2", "F1", "F2", "M"]
  428. readArr.push("Own")
  429. let data = showTools.changeHeader(arr, readArr, false, this.isWatch, false, true)
  430. data.unshift("所属建筑楼层");
  431. console.log(data, "data")
  432. return data;
  433. },
  434. /**
  435. * 表头数据处理函数
  436. * @param list header数组数据
  437. *
  438. * @return 处理好的数据格式
  439. */
  440. getType(list) {
  441. let arr = tools.copyArr(list)
  442. // 如果不是只读状态,添加四大厂商选择
  443. if (!this.onlyRead) {
  444. arr = showTools.arrToArr(arr)
  445. }
  446. let data = showTools.showTypes(arr, false, this.isWatch, false, true)
  447. data.unshift(
  448. {
  449. data: "flowBuild",
  450. renderer: tools.customDropdownRenderer,
  451. editor: "chosen",
  452. chosenOptions: {
  453. data: this.floorData
  454. }
  455. }
  456. );
  457. console.log("type", data)
  458. return data;
  459. },
  460. //初始化插件
  461. initHot() {
  462. var container = document.getElementById("myHandson");
  463. let winHeight = document.documentElement.clientHeight;
  464. this.hot = new Handsontable(container, {
  465. data: this.main,
  466. colHeaders: this.delHeader(this.headers), //表头文案
  467. columns: this.getType(this.headers), //数据显示格式
  468. filters: true,
  469. rowHeaders: true,
  470. height: winHeight - 100 - 50 - 60,
  471. columnSorting: true, //添加排序
  472. sortIndicator: true, //添加排序
  473. renderAllRows: true,
  474. autoColumnSize: true,
  475. language: "zh-CN",
  476. maxRows: this.main.length,
  477. manualColumnResize: true,
  478. manualColumnMove: true,
  479. dropdownMenu: [
  480. "filter_by_condition",
  481. "filter_by_value",
  482. "filter_action_bar"
  483. ],
  484. contextMenu: this.onlyRead ? false :{
  485. items: {
  486. remove_row: {
  487. name: "删除该资产"
  488. }
  489. }
  490. },
  491. afterChange: this.tdChange, //修改后
  492. afterFilter: this.trimmedRows, //排序前
  493. afterRemoveRow: this.romoveFm, //右键删除
  494. afterOnCellMouseDown: this.eventClick //鼠标点击
  495. });
  496. let pro = document.getElementById("hot-display-license-info");
  497. if (!!pro) {
  498. pro.parentNode.removeChild(pro);
  499. }
  500. this.isLoading = false;
  501. },
  502. tdChange() {
  503. tools.setItem(this.deviceType.code, this.main)
  504. },
  505. //表格中的点击
  506. eventClick(el, rowArr) {
  507. //点击的是表头
  508. if (rowArr.row < 0) {
  509. return;
  510. }
  511. let filter = this.filtersArr;
  512. //被筛选过后的数组
  513. let trimmedArr = this.trimmedRows();
  514. //是否启用了排序
  515. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  516. if (trimmedArr.length && isSort) {
  517. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  518. .__arrayMap;
  519. let infos = this.main[trimmedArr[sortArr[rowArr.row]]];
  520. this.getInfors(infos, sortArr[rowArr.row]);
  521. } else if (isSort) {
  522. //排序后的数组
  523. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  524. let infos = this.main[sortArr[rowArr.row]];
  525. this.getInfors(infos, sortArr[rowArr.row]);
  526. } else if (trimmedArr.length) {
  527. let infos = this.main[trimmedArr[rowArr.row]];
  528. this.getInfors(infos, trimmedArr[rowArr.row]);
  529. } else {
  530. let infos = this.main[rowArr.row];
  531. this.getInfors(infos, rowArr);
  532. }
  533. },
  534. getInfors(infos, row) {
  535. //其他的开始判断
  536. let val = this.hot.colToProp(row.col);
  537. if (val == "infos.EquipQRCode") {
  538. this.myDialog.qrcode = true;
  539. this.$refs.qrcode.getCanvas(1111);
  540. }
  541. if (val == "linkSystem") {
  542. this.systemList = this.main[row.row].linkSystem || []
  543. this.dialog.systemType = true
  544. }
  545. if (val == "infos.DPManufacturerID") {
  546. this.myDialog.firm = true;
  547. }
  548. if (val == "infos.SupplierContractID") {
  549. let falg = null
  550. if (!!this.main[row.row].infos) {
  551. if (!!this.main[row.row].infos) {
  552. falg = this.main[row.row].infos.DPSupplierID.split("-")[0]
  553. }
  554. }
  555. if (!!falg) {
  556. this.id = falg
  557. this.myDialog.supply = true;
  558. } else {
  559. this.$message("请先选择供应商")
  560. }
  561. }
  562. if (val == "infos.InsuranceNum") {
  563. //选择保单
  564. let falg = null
  565. if (!!this.main[row.row].infos) {
  566. if (!!this.main[row.row].infos) {
  567. falg = this.main[row.row].infos.DPInsurerID.split("-")[0]
  568. }
  569. }
  570. if (!!falg) {
  571. this.id = falg
  572. this.myDialog.guarantee = true;
  573. } else {
  574. this.$message("请先选择保险商")
  575. }
  576. }
  577. if (val == "infos.InsuranceFile" || val == "infos.Archive") {
  578. this.filesArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
  579. this.myDialog.uploadFiles = true
  580. }
  581. if (
  582. val == "infos.InstallPic" ||
  583. val == "infos.InstallDrawing" ||
  584. val == "infos.Nameplate" ||
  585. val == "infos.Drawing"
  586. ) {
  587. if (val == "infos.Nameplate") {
  588. this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]].key] : []) : []
  589. } else {
  590. this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
  591. }
  592. this.myDialog.uploadImgs = true
  593. }
  594. if (val == "infos.Pic") {
  595. this.picsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
  596. this.myDialog.pic = true
  597. }
  598. if (
  599. val == "infos.Supplier"
  600. ) {
  601. this.myDialog.supplier = true;
  602. }
  603. if (
  604. val == "infos.DPSupplierID"
  605. ) {
  606. this.myDialog.supplier = true;
  607. }
  608. if (val == "infos.DPMaintainerID"
  609. ) {
  610. this.myDialog.maintainer = true;
  611. }
  612. if (
  613. val == "infos.DPInsurerID"
  614. ) {
  615. this.myDialog.insurer = true;
  616. }
  617. if (val == "infos.Maintainer") {
  618. this.myDialog.maintainer = true;
  619. }
  620. if (
  621. val == "infos.Insurer" ||
  622. val == "infos.InsurerContactor") {
  623. this.myDialog.insurer = true;
  624. }
  625. this.row = row.row
  626. this.messKey = val
  627. console.log(val, row);
  628. },
  629. //获取被筛选掉的行号
  630. trimmedRows() {
  631. // var plugin = hot.getPlugin('trimRows').trimmedRows;//获取被筛选掉的行号
  632. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  633. let dataLength = this.main.length;
  634. let dataArr = new Array();
  635. for (let i = 0; i < dataLength; i++) {
  636. dataArr.push(i);
  637. }
  638. if (plugin.length <= 0) {
  639. dataArr = undefined;
  640. } else {
  641. dataArr = this.array_diff(dataArr, plugin);
  642. }
  643. return dataArr || [];
  644. // var DataArray = new Array();
  645. // for (var i = 0; i < plugin.length; i++) {
  646. // // 通过行号获取数据
  647. // DataArray.push(this.hot.getSourceDataAtRow(plugin[i]));
  648. // }
  649. },
  650. //判断是否为空行
  651. isEmptyRow(instance, row) {
  652. var rowData = instance.countRows();
  653. for (var i = 0, ilen = rowData.length; i < ilen; i++) {
  654. if (rowData[i] !== null) {
  655. return false;
  656. }
  657. }
  658. return true;
  659. },
  660. //选择型号修改
  661. firmChange(data) {
  662. for (let key in data) {
  663. // this.utilToKey(key, "brand", data, "Brand")
  664. // this.utilToKey(key, "name", data, "Specification")
  665. // this.utilToKey(key, "venderName", data, "Manufacturer")
  666. if (key == "venderId") {
  667. data[key] = data[key] + "-" + data.name + "/" + data.brand
  668. this.utilToKey(key, "venderId", data, "DPManufacturerID")
  669. }
  670. this.utilToKey(key, "specificationId", data, "DPSpecificationID")
  671. }
  672. tools.setItem(this.deviceType.code, this.main)
  673. },
  674. //如果选择供应商之后
  675. supplierChange(data) {
  676. for (let key in data) {
  677. // this.utilToKey(key, "name", data, "Supplier")
  678. // this.utilToKey(key, "email", data, "SupplierEmail")
  679. // this.utilToKey(key, "website", data, "SupplierWeb")
  680. // this.utilToKey(key, "phone", data, "SupplierPhone")
  681. // this.utilToKey(key, "fox", data, "SupplierFax")
  682. // this.utilToKey(key, "man", data, "SupplierContactor")
  683. if (key == "venderId") {
  684. data[key] = data[key] + "-" + data.name
  685. console.log(data)
  686. this.utilToKey(key, "venderId", data, "DPSupplierID")
  687. }
  688. // this.utilToKey(key, "specificationId", data, "DPSpecificationID")
  689. }
  690. tools.setItem(this.deviceType.code, this.main)
  691. },
  692. //供应商合同
  693. supplyChange(data) {
  694. let changeData = { id: data }
  695. this.utilToKey("id", "id", changeData, "SupplierContractID")
  696. tools.setItem(this.deviceType.code, this.main)
  697. },
  698. //保险合同
  699. guaranteeChange(data) {
  700. for (let key in data) {
  701. this.utilToKey(key, "insuranceNo", data, "InsuranceNum")
  702. if (key == "contractFile") {
  703. if (!!data[key]) {
  704. data[key] = [data[key]]
  705. }
  706. }
  707. this.utilToKey(key, "contractFile", data, "InsuranceFile")
  708. }
  709. tools.setItem(this.deviceType.code, this.main)
  710. },
  711. //保险商变更
  712. changeInsurer(data) {
  713. for (let key in data) {
  714. // this.utilToKey(key, "name", data, "Insurer")
  715. // this.utilToKey(key, "email", data, "InsurerEmail")
  716. // this.utilToKey(key, "website", data, "InsurerWeb")
  717. // this.utilToKey(key, "phone", data, "InsurerFax")
  718. // this.utilToKey(key, "man", data, "InsurerContactor")
  719. if (key == "venderId") {
  720. data[key] = data[key] + "-" + data.name
  721. this.utilToKey(key, "venderId", data, "DPInsurerID")
  722. }
  723. }
  724. tools.setItem(this.deviceType.code, this.main)
  725. },
  726. //维修商变更
  727. changeMaintainer(data) {
  728. for (let key in data) {
  729. // this.utilToKey(key, "name", data, "Maintainer")
  730. // this.utilToKey(key, "email", data, "MaintainerEmail")
  731. // this.utilToKey(key, "website", data, "MaintainerWeb")
  732. // this.utilToKey(key, "phone", data, "MaintainerPhone")
  733. // this.utilToKey(key, "fox", data, "MaintainerFax")
  734. // this.utilToKey(key, "man", data, "MaintainerContactor")
  735. if (key == "venderId") {
  736. data[key] = data[key] + "-" + data.name
  737. this.utilToKey(key, "venderId", data, "DPMaintainerID")
  738. }
  739. }
  740. tools.setItem(this.deviceType.code, this.main)
  741. },
  742. utilToKey(key, name, data, messName) {
  743. if (key == name) {
  744. this.setDataToMain(data[key], messName, this.row)
  745. }
  746. },
  747. //上传文件弹窗触发事件
  748. fileChange(keys) {
  749. this.setDataToMain(keys[0], this.messKey.split("."), this.row)
  750. tools.setItem(this.deviceType.code, this.main)
  751. },
  752. //上传图片弹窗触发事件
  753. imgChange(keys) {
  754. console.log(keys, "keys", this.messKey.split("."), this.row,'22222222222222')
  755. this.setDataToMain(keys[0], this.messKey.split("."), this.row)
  756. tools.setItem(this.deviceType.code, this.main)
  757. },
  758. //设备图片弹窗改变事件
  759. changePics(keys) {
  760. console.log(keys, "keys", this.messKey.split("."), this.row,'22222222222222')
  761. this.setDataToMain(keys, this.messKey.split("."), this.row)
  762. tools.setItem(this.deviceType.code, this.main)
  763. },
  764. //判断是否有值,有值赋值
  765. setDataToMain(data, key, row) {
  766. if (!!data && data != '--') {
  767. if (!!this.main[row].infos) {
  768. //铭牌照片特殊处理
  769. this.main[row].infos[key] = data
  770. } else {
  771. this.main[row].infos = {}
  772. this.main[row].infos[key] = data
  773. }
  774. } else {
  775. this.main[row].infos[key] = ''
  776. }
  777. }
  778. },
  779. watch: {
  780. dialog: {
  781. deep: true,
  782. handler: function () {
  783. if (this.dialog.addDevice) {
  784. this.setValue()
  785. }
  786. }
  787. }
  788. }
  789. };
  790. </script>
  791. <style lang="less" scoped>
  792. #addDevice {
  793. overflow: hidden;
  794. }
  795. </style>