dialogAssets.vue 24 KB

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