device.vue 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384
  1. <template>
  2. <div style="height: calc(100% - 44.5px);padding: 0px 10px 10px;box-sizing: border-box;" v-loading="loading">
  3. <div class="hanson-bar">
  4. <div style="float:right;overflow:hidden;">
  5. <!-- <span style="width:20px;float:left;display:block;height:20px;cursor: pointer;" @click="changeAssetsFalg">
  6. <i v-show="!onlyRead" class="el-icon-fa el-icon-fa-compass"></i>
  7. </span> -->
  8. <span>当前筛选条件下共{{page.total || '--'}}设备</span>
  9. </div>
  10. <el-select v-model="onlyRead" @change="getHeaderData(mess)"
  11. style="width:100px;margin-right:20px;vertical-align:bottom;">
  12. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
  13. </el-select>
  14. <el-select v-model="showType" @change="initTable" style="width:100px;margin-right:10px;vertical-align:bottom;">
  15. <el-option v-for="item in showTypes" :key="item.value" :label="item.label" :value="item.value"></el-option>
  16. </el-select>
  17. <!-- <el-button size="small" style='width: 80px;' @click="download" icon="iconfont icon-xiazai">下载</el-button> -->
  18. <el-button size="small" style='width: 80px;' @click="addDevice">添加设备</el-button>
  19. <el-button size="small" @click="Batch" v-show="!onlyRead" :disabled="!(tableData && tableData.length)">批量维护信息点</el-button>
  20. <el-button size="small" style='width: 80px;' @click="reset">刷新</el-button>
  21. <el-button size="small" style='width: 80px;' v-show="!onlyRead" @click="undo">撤销</el-button>
  22. </div>
  23. <!-- 二维码弹窗 -->
  24. <qrcode :dialog="myDialog" :qrcodeUrl="qrcodeUrl" :addBody="true" ref="qrcode"></qrcode>
  25. <!-- 型号弹窗 -->
  26. <firm
  27. :mess="{deviceId: deviceType.assetType}"
  28. :firmDataType="firmDataType"
  29. ref="firm"
  30. @changeFirm="firmChange"
  31. :dialog="myDialog"
  32. ></firm>
  33. <!-- 供应商合同弹窗 -->
  34. <supply-dialog ref="supply" @change="supplyChange" :id="id" :dialog="myDialog"/>
  35. <!-- 供应商弹窗 -->
  36. <supplier-dialog ref="supplier" :firmDataType="firmDataType" @changeSupplier="supplierChange" :dialog="myDialog"/>
  37. <guarantee-dialog :id="id" ref="guarantee" @change="guaranteeChange" :dialog="myDialog"/>
  38. <!-- 上传文件-->
  39. <upload-files-dialog
  40. :read="onlyRead ? true : false"
  41. ref="upload"
  42. @changeFile="fileChange"
  43. :keysArr="filesArr"
  44. :firmDataType="firmDataType"
  45. :information="information"
  46. :infoType="infoType"
  47. :dialog="myDialog"
  48. />
  49. <!-- 上传图片-->
  50. <upload-img-dialog
  51. :read="onlyRead ? true : false"
  52. @changeFile="imgChange"
  53. :keysArr="imgsArr"
  54. :dialog="myDialog"
  55. :firmDataType="firmDataType"
  56. :information="information"
  57. :infoType="infoType"
  58. />
  59. <!-- 维修商信息-->
  60. <maintainer-dialog @changeMaintainer="changeMaintainer" :firmDataType="firmDataType" ref="maintainer"
  61. :dialog="myDialog"/>
  62. <insurer-dialog @changeInsurer="changeInsurer" :firmDataType="firmDataType" ref="insurer" :dialog="myDialog"/>
  63. <pic-dialog
  64. :read="onlyRead ? true : false"
  65. :dialog="myDialog"
  66. :keysArr="picsArr"
  67. @change="changePics"
  68. :firmDataType="firmDataType"
  69. :information="information"
  70. :infoType="infoType"
  71. />
  72. <div class=" middle_sty" style="height: 91%; text-align:center"
  73. v-show="!mess.deviceId && (!tableData || !tableData.length)">
  74. <p>
  75. <i class="icon-wushuju iconfont"></i>
  76. 请选择设备族
  77. </p>
  78. </div>
  79. <div class="center middle_sty" style="height: 91%" v-show="mess.deviceId && (!tableData || !tableData.length)">
  80. <p>
  81. <i class="icon-wushuju iconfont"></i>
  82. 暂无数据
  83. </p>
  84. </div>
  85. <div v-show="mess.deviceId && tableData && tableData.length" id="handsontable" ref="handsontable"></div>
  86. <div v-show="mess.deviceId && tableData && tableData.length" class="right">
  87. <my-pagination @change="getTableData" :page="page" :key="pageKey"></my-pagination>
  88. </div>
  89. <details-dialog :iframeSrc="iframeSrc" v-if="myDialog.details" :dialog="myDialog"></details-dialog>
  90. <!-- 关联的系统 -->
  91. <system-type :device="mess" :curDevice="curDevice" :dialog="myDialog" :type="onlyRead?'read':'edit'"
  92. @change="changeSystemType"
  93. :list="systemList"></system-type>
  94. <!-- 关联资产 -->
  95. <change-rea @changeProperty="changeProperty" :dialog="myDialog" :category="deviceType"></change-rea>
  96. <look-pic :dialog="myDialog" :keysArr="picsArr"></look-pic>
  97. <!-- 不支持的输入方式 -->
  98. <el-dialog title="临时维护信息点" :visible.sync="myDialog.update" @close="handleCloseUpdate" width="670px">
  99. <el-row>
  100. 该信息点未定义对应组件,现在维护数据不确定后续是否可用。如确实需要维护,请点击
  101. <el-link @click="updateInputShow = true" type="primary" :underline="false">继续维护</el-link>
  102. </el-row>
  103. <el-row style="margin-top:20px;" v-show="updateInputShow">
  104. <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 8}" placeholder="请输入内容"
  105. v-model="updateInput"></el-input>
  106. </el-row>
  107. <span slot="footer" class="dialog-footer">
  108. <el-button @click="myDialog.update = false">取 消</el-button>
  109. <el-button type="primary" @click="handleClickUpdate">确 认</el-button>
  110. </span>
  111. </el-dialog>
  112. <!-- 新增设备 -->
  113. <el-dialog title="确定新增设备的类型" :visible.sync="myDialog.addDevice" width="670px">
  114. <el-row>
  115. <my-cascader ref="cascader" @change="changeAddType" :all="true"></my-cascader>
  116. </el-row>
  117. <span slot="footer" class="dialog-footer">
  118. <el-button type="primary" @click="toAddDevice">下 一 步</el-button>
  119. </span>
  120. </el-dialog>
  121. <!-- 维护信息弹窗-->
  122. <batchDialog
  123. ref="batchDialogs"
  124. @code="fourVendors"
  125. :firmName="firmName"
  126. :allObject="allObject"
  127. :page="batchPage"
  128. :information="information"
  129. @getAllData="getAllData"
  130. @multiple="multiple"
  131. @upDataDevice="upDataDevice"
  132. />
  133. </div>
  134. </template>
  135. <script>
  136. import {
  137. BeatchQueryParam,
  138. deleteEquip,
  139. getDataDictionary,
  140. getEquipBelongs,
  141. getEquipTableCon,
  142. queryEquip,
  143. queryUpdate,
  144. updateEquip
  145. } from "@/api/scan/request";
  146. import tools from "@/utils/scan/tools"
  147. import handsonUtils from "@/utils/hasontableUtils"
  148. import showTools from "@/utils/handsontable/notShow"
  149. import text from "@/utils/handsontable/mainText"
  150. import myCascader from "@/components/ledger/lib/cascader"
  151. import buildFloor from '@/utils/handsontable/buildFloorData'
  152. import qrcode from "@/components/ledger/lib/qrcode"
  153. import firm from "@/components/dialogs/list/firm"
  154. import supplyDialog from "@/components/dialogs/list/supplyDialog"
  155. import supplierDialog from "@/components/dialogs/list/supplierDialog"
  156. import maintainerDialog from "@/components/dialogs/list/maintainerDialog"
  157. import insurerDialog from "@/components/dialogs/list/insurerDialog"
  158. import guaranteeDialog from "@/components/dialogs/list/guaranteeDialog"
  159. import uploadFilesDialog from "@/components/dialogs/list/filesDialog"
  160. import uploadImgDialog from "@/components/dialogs/list/uploadImgDialog"
  161. import picDialog from "@/components/dialogs/list/picDialog"
  162. import batchDialog from "../../dialogs/list/batchDialog";
  163. import systemType from "@/components/dialogs/list/systemType"
  164. import myPagination from "@/components/ledger/lib/myPagination"
  165. import detailsDialog from "@/components/ledger/lib/detailsDia"
  166. import changeRea from "@/components/dialogs/changeRea"
  167. import {mapGetters} from "vuex"
  168. //图片查看
  169. import lookPic from "@/components/ledger/lib/lookImages"
  170. import Handsontable from "handsontable-pro"
  171. import 'handsontable-pro/dist/handsontable.full.css'
  172. import lStorage from '@/utils/localStorage'
  173. //下拉插件
  174. // import "@/assets/js/chosen.jquery.min";
  175. // import "@/assets/js/handsontable-chosen-editor";
  176. export default {
  177. props: ["myParam"],
  178. components: {
  179. qrcode, //二维码页面
  180. firm, //
  181. supplyDialog,
  182. supplierDialog,
  183. guaranteeDialog,
  184. uploadFilesDialog,
  185. maintainerDialog,
  186. insurerDialog,
  187. uploadImgDialog,
  188. picDialog,
  189. myPagination,
  190. systemType,
  191. detailsDialog,
  192. changeRea,
  193. lookPic,
  194. myCascader,
  195. batchDialog
  196. },
  197. created() {
  198. buildFloor.getData(this.buildFloorData)
  199. },
  200. computed: {
  201. ...mapGetters("layout", ["projectId", "secret", "userId"]),
  202. showTypes() {
  203. return this.onlyRead ?
  204. [{value: "Visible", label: '只看采集信息'}, {value: "all", label: '全部'}] :
  205. [{value: "partInfo", label: '隐藏信息点'}, {value: "all", label: '全部'}, {value: "Visible", label: '只看采集信息'}]
  206. },
  207. // batchDate() {
  208. // // return !(!this.onlyRead && this.copyMain)
  209. // return !(!this.onlyRead && this.page.total > 1)
  210. // },
  211. batchDialogShow() {
  212. return this.$refs.batchDialogs.batchDialog
  213. }
  214. },
  215. data() {
  216. return {
  217. options: [{
  218. value: true,
  219. label: '只读模式'
  220. }, {
  221. value: false,
  222. label: '编辑模式'
  223. }],
  224. buildFloorData: [], //楼层数据
  225. tableData: [],
  226. mess: {},
  227. tableHeader: null,
  228. page: {
  229. size: 50,
  230. sizes: [10, 30, 50, 100, 150, 200],
  231. total: 0,
  232. currentPage: 1
  233. },
  234. pageKey: new Date().getTime(),
  235. batchPage: {
  236. size: 50,
  237. sizes: [10, 30, 50, 100, 150, 200],
  238. total: 0,
  239. currentPage: 1
  240. },
  241. myDialog: {
  242. qrcode: false, //二维码弹窗
  243. firm: false, //厂商弹窗
  244. supply: false, //选择供应合同
  245. supplier: false, //供应商选择
  246. guarantee: false, //选择保单
  247. maintainer: false, //选择维修商
  248. insurer: false, //选择保险公司
  249. uploadFiles: false,//上传文件
  250. uploadImgs: false,//上传单个图片
  251. pic: false, //多个图片
  252. addDevice: false,//添加设备
  253. systemType: false,//关联系统
  254. details: false,//详情页
  255. changeRea: false,//关联资产
  256. lookPic: false,//图片查看
  257. update: false,//临时维护信息点
  258. },
  259. row: null, //被修改的row
  260. filesArr: [], //保存临时的文件key
  261. messKey: null,
  262. imgsArr: [], //临时保存的图片key数组
  263. picsArr: [], //临时设备图片keys数组
  264. systemList: [], //关联的系统
  265. copyMain: null,
  266. iframeSrc: "",
  267. id: 0,
  268. onlyRead: true,
  269. showType: 'Visible',
  270. linkNameFalg: true,
  271. qrcodeUrl: "", //二维码图片地址
  272. loading: false,
  273. deviceType: {}, //族3位编码及名称
  274. floorData: [],
  275. curDevice: '',//当前点击的设备id
  276. addData: {}, //添加设备选择的设备类型
  277. inputMap: {
  278. flowBuild: 'D1'
  279. }, //信息点和输入方式映射表
  280. updateInputShow: false, //是否显示临时维护输入框
  281. updateInfoPoint: '',//临时维护信息点
  282. updateInput: '', //临时维护信息点值
  283. firmName: '',//维护信息显示厂家名称
  284. firmDataType: 'row',
  285. allObject: [],
  286. information: {
  287. archive: {
  288. Archive: [], //设备文档
  289. name: '设备文档',
  290. code: 'LedgerParam.PhotoDoc.Archive',
  291. num: 14
  292. },
  293. checkReport: {
  294. CheckReport: [],//安装质检报告
  295. name: '安装质检报告',
  296. code: 'LedgerParam.Siteinstall.CheckReport',
  297. num: 18
  298. },
  299. drawing: {
  300. Drawing: [],//设备图纸
  301. name: '设备图纸',
  302. code: 'LedgerParam.PhotoDoc.Drawing',
  303. num: 13
  304. },
  305. installDrawing: {
  306. InstallDrawing: [],//安装图纸
  307. name: '安装图纸',
  308. code: 'LedgerParam.Siteinstall.InstallDrawing',
  309. num: 16
  310. },
  311. installPic: {
  312. InstallPic: [],//安装照片
  313. name: '安装照片',
  314. code: 'LedgerParam.Siteinstall.InstallPic',
  315. num: 17
  316. },
  317. insuranceFile: {
  318. InsuranceFile: [],//保险文件
  319. name: '保险文件',
  320. code: 'LedgerParam.InsuranceDoc.InsuranceFile',
  321. num: 11
  322. },
  323. nameplate: {
  324. Nameplate: [],//设备铭牌照片
  325. name: '设备铭牌照片',
  326. code: 'LedgerParam.PhotoDoc.Nameplate',
  327. num: 12
  328. },
  329. pic: {
  330. Pic: [],//设备照片
  331. name: '设备照片',
  332. code: 'LedgerParam.PhotoDoc.Pic',
  333. num: 15
  334. }
  335. },
  336. infoType: ''
  337. };
  338. },
  339. methods: {
  340. //获取表头
  341. getHeaderData(code) {
  342. let tempParams = this.$route.params;
  343. if (!tempParams.used && tempParams.pageSize) {
  344. this.page.currentPage = tempParams.pageNo;
  345. this.page.size = tempParams.pageSize;
  346. this.onlyRead = tempParams.readOnly;
  347. tempParams.used = true;
  348. } else {
  349. this.page.currentPage = 1
  350. }
  351. this.pageKey = new Date().getTime();
  352. this.mess = code
  353. this.changeCader()
  354. if (this.mess.deviceId) {
  355. let params = {
  356. data: {
  357. Orders: "sort asc",
  358. PageNumber: 1,
  359. PageSize: 1000
  360. },
  361. type: this.mess.deviceId
  362. };
  363. getDataDictionary(params, res => {
  364. this.tableHeader = res.Content;
  365. this.tableHeader.forEach(item => {
  366. if (item.Path && item.InputMode) {
  367. this.inputMap[item.Path] = item.InputMode
  368. }
  369. })
  370. this.getTableData()
  371. this.getAllData()
  372. });
  373. }
  374. },
  375. //获取主体数据
  376. getTableData() {
  377. this.loading = true
  378. //type存在发送请求
  379. if (!!this.mess.deviceId) {
  380. let param = {
  381. PageSize: this.page.size,
  382. Orders: "createTime desc, EquipID desc",
  383. PageNumber: this.page.currentPage,
  384. Filters: `category='${this.mess.deviceId}'`
  385. }
  386. if (this.mess.buildId == "noKnow") {
  387. param.Filters += `;buildingId isNull`
  388. } else if (this.mess.buildId && this.mess.buildId != "all") {
  389. param.Filters += `;buildingId='${this.mess.buildId}'`
  390. }
  391. if (this.mess.floorId == "noKnow") {
  392. param.Filters += `;floorId isNull`
  393. } else if (this.mess.floorId && this.mess.floorId != "all") {
  394. param.Filters += `;floorId='${this.mess.floorId}'`
  395. }
  396. getEquipTableCon(param, res => {
  397. this.loading = false;
  398. this.tableData = res.Content.map((item) => {
  399. if (item.hasOwnProperty("BuildingId") && item.hasOwnProperty("FloorId")) {
  400. item.flowBuild = item.BuildingId + "-" + item.FloorId
  401. } else if (item.hasOwnProperty("BuildingId") && !item.hasOwnProperty("FloorId")) {
  402. item.flowBuild = item.BuildingId
  403. }
  404. return item
  405. });
  406. this.copyMain = tools.deepCopy(this.tableData);
  407. this.page.total = res.Total;
  408. if (this.tableData && this.tableData.length) {
  409. if (this.onlyRead) {
  410. this.getBatch(this.tableData)
  411. }
  412. this.initTable();
  413. }
  414. })
  415. }
  416. },
  417. //获取所以主体数据---用于维护信息
  418. getAllData() {
  419. if (!!this.mess.deviceId) {
  420. // 查询step2
  421. let params = {
  422. "Cascade": [
  423. {
  424. "Name": "property",
  425. "Projection": [
  426. "Family", "EquipLocalName", "EquipLocalID", "EquipID", "CodeType"
  427. ]
  428. },
  429. {
  430. "Name": "building",
  431. "Projection": [
  432. "BuildLocalName", "BuildName", "BuildID"
  433. ]
  434. },
  435. {
  436. "Name": "floor",
  437. "Projection": [
  438. "FloorLocalName", "FloorName", "FloorID"
  439. ]
  440. }
  441. ],
  442. Filters: `category='${this.mess.deviceId}'`,
  443. PageSize: this.batchPage.size,
  444. Orders: "createTime desc, EquipID desc",
  445. PageNumber: this.batchPage.currentPage,
  446. "Projection": [
  447. "BuildingId", "FloorId", "Category", "EquipLocalName", "EquipLocalID", "EquipID", "BIMID"
  448. ]
  449. };
  450. if (this.mess.buildId == "noKnow") {
  451. params.Filters += `;buildingId isNull`
  452. } else if (this.mess.buildId && this.mess.buildId != "all") {
  453. params.Filters += `;buildingId='${this.mess.buildId}'`
  454. }
  455. if (this.mess.floorId == "noKnow") {
  456. params.Filters += `;floorId isNull`
  457. } else if (this.mess.floorId && this.mess.floorId != "all") {
  458. params.Filters += `;floorId='${this.mess.floorId}'`
  459. }
  460. queryEquip(params, res => {
  461. this.allObject = res.Content
  462. this.batchPage.total = res.Total
  463. })
  464. }
  465. },
  466. //获取动态参数
  467. getBatch(data) {
  468. let param = {
  469. secret: this.secret,
  470. ProjId: this.projectId,
  471. data: {
  472. criterias: []
  473. }
  474. }
  475. //一级遍历list
  476. this.tableHeader.map(head => {
  477. //如果一级标签为动态参数或者设定参数放入数据等待请求
  478. if (
  479. head.InputMode == "L" ||
  480. head.InputMode == "L1" ||
  481. head.InputMode == "L2" ||
  482. head.InputMode == "M"
  483. ) {
  484. data.map(item => {
  485. let cur = tools.dataForKey(item, head.Path);
  486. if (cur) {
  487. param.data.criterias.push({
  488. id: item.EquipID,
  489. code: head.InfoPointCode
  490. });
  491. }
  492. });
  493. }
  494. })
  495. if (param.data.criterias.length) {
  496. BeatchQueryParam(param, res => {
  497. if (!this.onlyRead) {
  498. return false
  499. }
  500. this.tableData = data.map(item => {
  501. res.Content.map(child => {
  502. if (item.EquipID == child.id) {
  503. if (!!child.data || child.data == 0) {
  504. this.tableHeader.map(head => {
  505. if (head.InfoPointCode == child.code) {
  506. tools.setDataForKey(item, head.Path, child.data);
  507. }
  508. });
  509. } else {
  510. this.tableHeader.map(head => {
  511. if (head.InfoPointCode == child.code) {
  512. tools.setDataForKey(
  513. item,
  514. head.Path,
  515. child.error ? child.value ? "表号功能号格式错误" : "表号功能号不存在" : "暂未采集到实时数据"
  516. );
  517. }
  518. });
  519. }
  520. }
  521. })
  522. return item
  523. })
  524. this.hot.loadData(this.tableData)
  525. })
  526. }
  527. },
  528. //修改资产
  529. changeAssetsFalg() {
  530. if (this.linkNameFalg) {
  531. this.linkNameFalg = false
  532. } else {
  533. this.$confirm('<p>真的要在这里修改设备关联的资产么?</p><p>真的能通过列表信息找到想关联的资产么?</p><p>在这里修改关联的资产一定是因为之前关联错了要修改么?</p>', '提示', {
  534. dangerouslyUseHTMLString: true,
  535. confirmButtonText: '没错!我要改关联的资产',
  536. cancelButtonText: '我就点开看看',
  537. confirmButtonClass: 'cancelButtonClass',
  538. cancelButtonClass: 'cancelButtonClass'
  539. }).then(_ => {
  540. this.linkNameFalg = true
  541. }).catch(_ => {
  542. this.$message("取消")
  543. })
  544. }
  545. },
  546. //撤回
  547. undo() {
  548. this.hot.undo();
  549. },
  550. //刷新-switch改变
  551. reset() {
  552. this.getTableData();
  553. },
  554. //添加设备
  555. addDevice() {
  556. this.myDialog.addDevice = true
  557. if (this.mess.deviceId) {
  558. this.$nextTick(() => {
  559. this.$refs.cascader.setValue(this.mess.deviceId)
  560. })
  561. }
  562. },
  563. //下一步
  564. toAddDevice() {
  565. if (this.addData.deviceId) {
  566. this.$router.push({
  567. path: "/ledger/deviceadd",
  568. query: this.addData
  569. });
  570. }
  571. },
  572. //选择设备类型-添加设备
  573. changeAddType(val) {
  574. this.addData.deviceId = val.code;
  575. this.addData.name = val.facility;
  576. },
  577. //下载
  578. download() {
  579. if (!this.onlyRead) {
  580. if (!!this.hot) {
  581. let fileName = this.mess.name + "-页数:" + this.page.currentPage + "-个数:" + this.tableData.length + "-总个数:" + this.page.total
  582. this.hot.getPlugin('exportFile').downloadFile("csv", {
  583. filename: fileName,
  584. columnHeaders: true,
  585. exportHiddenRows: true,
  586. exportHiddenColumns: true,
  587. rowHeaders: true
  588. })
  589. } else {
  590. this.$message("请确定存在表格")
  591. }
  592. } else {
  593. this.$message("下载需在编辑状态下")
  594. }
  595. },
  596. //格式化表头
  597. formatHeaderData(list) {
  598. let arr = tools.copyArr(list)
  599. let data = showTools.headerTextFilter(arr, 'equipment', this.onlyRead, this.showType, true)
  600. data.unshift("操作", "当前关联的资产", "所属系统实例", "包含的部件");
  601. if (this.showType == "all") {
  602. data.splice(6, 0, "所属建筑楼层")
  603. }
  604. return data;
  605. },
  606. //格式化表内容
  607. formatHeaderType(list) {
  608. let arr = tools.copyArr(list)
  609. let data = showTools.headerTypeFilter(arr, 'equipment', this.onlyRead, this.showType, true)
  610. data.unshift(
  611. {
  612. data: "caozuo",
  613. renderer: tools.lookDetails,
  614. readOnly: true
  615. },
  616. {
  617. data: "LinkEquipLocalName",
  618. readOnly: true,
  619. renderer: tools.LinkEquipLocalName
  620. }, {
  621. data: "LinkSystem",
  622. renderer: text.systemList,
  623. readOnly: true
  624. }, {
  625. data: "Count",
  626. readOnly: true,
  627. renderer: tools.lookDetails
  628. }
  629. );
  630. if (this.showType == "all") {
  631. data.splice(6, 0, {
  632. data: "flowBuild",
  633. renderer: tools.customDropdownRenderer,
  634. editor: "chosen",
  635. chosenOptions: {
  636. data: this.buildFloorData
  637. },
  638. readOnly: this.onlyRead
  639. })
  640. }
  641. return data;
  642. },
  643. //初始化插件
  644. initTable() {
  645. var container = document.getElementById("handsontable");
  646. let winHeight = document.documentElement.clientHeight;
  647. if (this.hot) {
  648. this.hot.destroy();
  649. this.hot = null;
  650. }
  651. this.hot = new Handsontable(container, {
  652. data: this.tableData,
  653. fixedColumnsLeft: 6,
  654. colHeaders: this.formatHeaderData(this.tableHeader), //表头文案
  655. columns: this.formatHeaderType(this.tableHeader), //数据显示格式
  656. filters: true,
  657. maxRows: this.tableData.length,
  658. height: winHeight - 335,
  659. columnSorting: true, //添加排序
  660. sortIndicator: true, //添加排序
  661. renderAllRows: true,
  662. // colWidths: 200,
  663. autoColumnSize: true,
  664. language: "zh-CN",
  665. manualColumnResize: true,
  666. manualColumnMove: true,
  667. dropdownMenu: [
  668. "filter_by_condition",
  669. "filter_by_value",
  670. "filter_action_bar"
  671. ],
  672. contextMenu: this.onlyRead ? false : {
  673. items: {
  674. remove_row: {
  675. name: "删除选中设备"
  676. }
  677. }
  678. },
  679. // 事件
  680. afterChange: this.handleUpdataTable, //修改后
  681. afterFilter: this.trimmedRows, //排序前
  682. afterRemoveRow: this.handleDeleteTableRow, //右键删除
  683. afterOnCellMouseDown: this.eventClick //鼠标点击
  684. });
  685. let pro = document.getElementById("hot-display-license-info");
  686. if (!!pro) {
  687. pro.parentNode.removeChild(pro);
  688. }
  689. this.isLoading = false;
  690. },
  691. //表格中的点击
  692. eventClick(el, rowArr) {
  693. //点击的是表头
  694. if (rowArr.row < 0) {
  695. return;
  696. }
  697. //被筛选过后的数组
  698. let trimmedArr = this.trimmedRows();
  699. //是否启用了排序
  700. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  701. if (trimmedArr.length && isSort) {
  702. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  703. .__arrayMap;
  704. let infos = this.tableData[trimmedArr[sortArr[rowArr.row]]];
  705. this.getInfors(infos, {row: sortArr[rowArr.row], col: rowArr.col}, el);
  706. } else if (isSort) {
  707. //排序后的数组
  708. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  709. let infos = this.tableData[sortArr[rowArr.row]];
  710. this.getInfors(infos, {row: sortArr[rowArr.row], col: rowArr.col}, el);
  711. } else if (trimmedArr.length) {
  712. let infos = this.tableData[trimmedArr[rowArr.row]];
  713. this.getInfors(infos, {row: trimmedArr[rowArr.row], col: rowArr.col}, el);
  714. } else {
  715. let infos = this.tableData[rowArr.row];
  716. this.getInfors(infos, rowArr, el);
  717. }
  718. },
  719. // 更新
  720. handleUpdataTable(changeData, source) {
  721. if (!this.onlyRead && source != 'ObserveChanges.change') {
  722. if (changeData) {
  723. let trimmedArr = this.trimmedRows();
  724. let param = handsonUtils.getParam(changeData, source, this.hot, trimmedArr);
  725. let data = [];
  726. for (let i = 0; i < param.length; i++) {
  727. data.push(param[i]);
  728. }
  729. //如果data中包含/且data长度为1,将其转换成.
  730. if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
  731. changeData[0][1] = changeData[0][1].split("/").join(".")
  732. }
  733. //存在data进行修改请求
  734. if (data && data.length) {
  735. this.updateBusiness(data, changeData);
  736. }
  737. }
  738. }
  739. },
  740. //删除设备
  741. handleDeleteTableRow() {
  742. let params = tools.differenceArr(this.tableData, this.copyMain)
  743. let _this = this
  744. if (params.length < 1) {
  745. return
  746. }
  747. let param = []
  748. params.map(item => {
  749. this.deleteCode = item.Category
  750. param.push({EquipID: item.EquipID})
  751. })
  752. this.$confirm("此操作将删除设备,是否继续?", "提示", {
  753. confirmButtonText: '确定',
  754. cancelButtonText: '取消',
  755. type: 'warning'
  756. }).then(() => {
  757. this.removeDevice(param)
  758. }).catch(() => {
  759. this.reset()
  760. this.$message("取消删除")
  761. })
  762. },
  763. // 删除设备
  764. async removeDevice(param) {
  765. await deleteEquip(param, res => {
  766. this.$message.success("删除成功")
  767. this.$emit('close', {code: this.deleteCode})
  768. // this.getTableData()
  769. })
  770. },
  771. // 更新
  772. updateBusiness(data, change) {
  773. let param = {
  774. Content: [],
  775. Projection: []
  776. }, keyList = [];
  777. //生成要修改字段列表
  778. change.map(item => {
  779. let key = item[1].split(".")[0]
  780. if (key == "flowBuild" && keyList.indexOf(key) == -1) {
  781. keyList.push("BuildingId", "FloorId")
  782. param.Projection.push("BuildingId", "FloorId")
  783. }
  784. if (item[1] && keyList.indexOf(key) == -1 && item[1] != 'PropertyId') {
  785. keyList.push(key);
  786. }
  787. if (item[1] && item[3] == "" && param.Projection.indexOf(key) == -1 && item[1] != 'PropertyId') {
  788. param.Projection.push(key);
  789. }
  790. });
  791. //生成对应修改数据
  792. data.map((item, index) => {
  793. keyList.map(value => {
  794. if (value == "BuildingId") {
  795. let itemData = tools.dataForKey(item, "flowBuild")
  796. if (itemData == "") {
  797. tools.setDataForKey(item, "BuildingId", null)
  798. tools.setDataForKey(item, "FloorId", null)
  799. } else {
  800. let BuildingId = itemData.split("-")[0]
  801. let FloorId = itemData.split("-")[1]
  802. if (BuildingId && FloorId) {
  803. tools.setDataForKey(item, "BuildingId", BuildingId)
  804. tools.setDataForKey(item, "FloorId", FloorId)
  805. } else if (BuildingId && !FloorId) {
  806. tools.setDataForKey(item, "BuildingId", BuildingId)
  807. tools.setDataForKey(item, "FloorId", null)
  808. }
  809. }
  810. } else {
  811. let itemData = tools.dataForKey(item, value)
  812. tools.setDataForKey(item, value, itemData == "" ? null : itemData)
  813. }
  814. });
  815. param.Content.push(item);
  816. });
  817. updateEquip(param, res => {
  818. });
  819. },
  820. //修改设备类型
  821. changeCader() {
  822. if (this.mess.deviceId) {
  823. let param = {
  824. data: {
  825. Filters: `EquipCode='${this.mess.deviceId}'`,
  826. PageNumber: 1,
  827. PageSize: 50
  828. }
  829. }
  830. getEquipBelongs(param, res => {
  831. if (res.Content.length) {
  832. this.deviceType.assetType = res.Content[0].Family
  833. this.deviceType.assetName = res.Content[0].FamilyName
  834. }
  835. })
  836. }
  837. },
  838. // 接受维护信息传来的code,显示弹窗
  839. fourVendors(code) {
  840. this.firmDataType = 'dialog'
  841. switch (code) {
  842. //品牌型号弹窗
  843. case 'DPManufacturerID':
  844. // this.dataFirmType = 'dia'
  845. this.myDialog.firm = true;
  846. break;
  847. //供应商信息弹窗
  848. case 'DPSupplierID':
  849. this.myDialog.supplier = true;
  850. break;
  851. //维修商信息弹窗
  852. case 'DPMaintainerID':
  853. this.myDialog.maintainer = true;
  854. break;
  855. //保险公司信息
  856. case 'DPInsurerID':
  857. this.myDialog.insurer = true;
  858. break;
  859. }
  860. },
  861. multiple(val) {
  862. this.firmDataType = 'dialog'
  863. switch (val) {
  864. //设备文档--安装质检报告--保险文件
  865. case 'archive':
  866. let adata = this.information.archive.Archive;
  867. this.filesArr = adata ? adata : [];
  868. this.infoType = 'archive';
  869. this.myDialog.uploadFiles = true;
  870. break;
  871. case 'checkReport':
  872. let cdata = this.information.checkReport.CheckReport;
  873. this.filesArr = cdata ? cdata : [];
  874. this.infoType = 'checkReport'
  875. this.myDialog.uploadFiles = true;
  876. break;
  877. case 'insuranceFile':
  878. let idata = this.information.insuranceFile.InsuranceFile;
  879. this.filesArr = idata ? idata : [];
  880. this.infoType = 'insuranceFile';
  881. this.myDialog.uploadFiles = true;
  882. break;
  883. //安装照片--安装图纸--设备铭牌照片--设备图纸
  884. case 'installPic':
  885. let insData = this.information.installPic.InstallPic;
  886. this.imgsArr = insData ? insData : [];
  887. this.infoType = 'installPic';
  888. this.myDialog.uploadImgs = true;
  889. break;
  890. case 'installDrawing':
  891. let drawData = this.information.installDrawing.InstallDrawing;
  892. this.imgsArr = drawData ? drawData : [];
  893. this.infoType = 'installDrawing';
  894. this.myDialog.uploadImgs = true;
  895. break;
  896. case 'nameplate':
  897. let nDate = this.information.nameplate.Nameplate;
  898. this.imgsArr = nDate ? nDate : [];
  899. this.infoType = 'nameplate';
  900. this.myDialog.uploadImgs = true;
  901. break;
  902. case 'drawing':
  903. let dDate = this.information.drawing.Drawing;
  904. this.imgsArr = dDate ? dDate : [];
  905. this.infoType = 'drawing';
  906. this.myDialog.uploadImgs = true;
  907. break;
  908. //设备照片
  909. case 'pic':
  910. let picData = this.information.pic.Pic;
  911. this.picsArr = picData ? picData : [];
  912. this.infoType = 'pic';
  913. this.myDialog.pic = true;
  914. break;
  915. }
  916. },
  917. //获取到了正确的信息
  918. getInfors(infos, row, el) {
  919. let val = this.hot.colToProp(row.col);
  920. let inputMode = this.inputMap[val];
  921. this.row = row.row;
  922. this.messKey = val;
  923. this.firmDataType = 'row'
  924. lStorage.set('screen_data', { path: this.$route.path, data: { equip: infos } })
  925. switch (val) {
  926. //操作
  927. case 'caozuo':
  928. // window.open(`http://adm.sagacloud.cn:8058/spread?id=${infos.EquipID}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
  929. // this.$message("开发中...")
  930. this.$router.push({
  931. path: "deviceDetails",
  932. query: {
  933. type: this.mess.deviceId,
  934. equipId: infos.EquipID,
  935. equipName: infos.EquipLocalName?infos.EquipLocalName:infos.EquipName?infos.EquipName:'',
  936. equipCode: infos.EquipLocalID?infos.EquipLocalID:'',
  937. data: this.tableData.map(item => {
  938. return {
  939. value: item.EquipID,
  940. label: item.EquipLocalName?item.EquipLocalName:item.EquipName?item.EquipName:''
  941. }
  942. })
  943. }
  944. })
  945. return false
  946. //设备二维码图片
  947. case 'EquipQRCode':
  948. this.qrcodeUrl = this.tableData[row.row].EquipQRCode;
  949. if (!!this.qrcodeUrl) {
  950. this.myDialog.qrcode = true;
  951. } else {
  952. this.$message("此设备没有设备二维码");
  953. }
  954. return false
  955. //关联系统
  956. case 'LinkSystem':
  957. if (!this.onlyRead) {
  958. this.curDevice = infos.EquipID;
  959. this.systemList = this.tableData[row.row].LinkSystem || [];
  960. this.myDialog.systemType = true;
  961. }
  962. return false
  963. //关联资产
  964. case 'LinkEquipLocalName':
  965. if (!this.onlyRead) {
  966. this.myDialog.changeRea = true;
  967. }
  968. return false
  969. //品牌型号弹窗
  970. case 'DPManufacturerID':
  971. if (!this.onlyRead) {
  972. this.myDialog.firm = true;
  973. }
  974. return false
  975. //供应商信息弹窗
  976. case 'DPSupplierID':
  977. if (!this.onlyRead) {
  978. this.myDialog.supplier = true;
  979. }
  980. return false
  981. //维修商信息弹窗
  982. case 'DPMaintainerID':
  983. if (!this.onlyRead) {
  984. this.myDialog.maintainer = true;
  985. }
  986. return false
  987. //保险公司信息
  988. case 'DPInsurerID':
  989. if (!this.onlyRead) {
  990. this.myDialog.insurer = true;
  991. }
  992. return false
  993. //供应合同编号
  994. case 'LedgerParam.SupplyPurchase.SupplierContractID':
  995. if (!this.onlyRead) {
  996. let ContractIDflag = null;
  997. let DPSdata = this.tableData[row.row].DPSupplierID;
  998. if (DPSdata) {
  999. ContractIDflag = DPSdata.split("-")[0];
  1000. }
  1001. if (!!ContractIDflag) {
  1002. this.id = ContractIDflag;
  1003. this.myDialog.supply = true;
  1004. } else {
  1005. this.$message("请先选择供应商");
  1006. }
  1007. }
  1008. return false
  1009. //保险单号
  1010. case 'LedgerParam.InsuranceDoc.InsuranceNum':
  1011. if (!this.onlyRead) {
  1012. let DPInsurerIDflag = null;
  1013. let DPIdata = this.tableData[row.row].DPInsurerID;
  1014. if (DPIdata) {
  1015. DPInsurerIDflag = DPIdata.split("-")[0];
  1016. }
  1017. if (!!DPInsurerIDflag) {
  1018. this.id = DPInsurerIDflag;
  1019. this.myDialog.guarantee = true;
  1020. } else {
  1021. this.$message("请先选择保险商");
  1022. }
  1023. }
  1024. return false
  1025. //保险文件--设备文档--安装质检报告
  1026. case 'LedgerParam.InsuranceDoc.InsuranceFile':
  1027. case 'LedgerParam.PhotoDoc.Archive':
  1028. case 'LedgerParam.Siteinstall.CheckReport':
  1029. let IPSdata = tools.dataForKey(this.tableData[row.row], val);
  1030. this.filesArr = IPSdata ? IPSdata : [];
  1031. if (!this.onlyRead || this.filesArr.length) {
  1032. this.myDialog.uploadFiles = true;
  1033. }
  1034. return false
  1035. //安装照片--安装图纸--设备铭牌照片--设备图纸
  1036. case 'LedgerParam.Siteinstall.InstallPic':
  1037. case 'LedgerParam.Siteinstall.InstallDrawing':
  1038. case 'LedgerParam.PhotoDoc.Nameplate':
  1039. case 'LedgerParam.PhotoDoc.Drawing':
  1040. let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
  1041. this.imgsArr = SSPPdata ? SSPPdata : [];
  1042. if (!this.onlyRead || this.imgsArr.length) {
  1043. this.myDialog.uploadImgs = true;
  1044. }
  1045. return false
  1046. //设备照片
  1047. case 'LedgerParam.PhotoDoc.Pic':
  1048. let Pdata = tools.dataForKey(this.tableData[row.row], val);
  1049. this.picsArr = Pdata ? Pdata : [];
  1050. if (!this.onlyRead || this.picsArr.length) {
  1051. this.myDialog.pic = true;
  1052. }
  1053. return false
  1054. //包含的部件字段
  1055. case 'Count':
  1056. let countUrl = this.onlyRead ? '/ledger/parts' : '/ledger/partsmanage';
  1057. this.$router.push({path: countUrl, query: {
  1058. deviceId: infos.EquipID,
  1059. typeId: this.mess.deviceId,
  1060. pageNo: this.page.currentPage,
  1061. pageSize: this.page.size
  1062. }});
  1063. return false
  1064. default:
  1065. break;
  1066. }
  1067. if (!this.onlyRead && showTools.InputModeArr.indexOf(inputMode) == '-1') {
  1068. this.updateInfoPoint = val
  1069. this.updateInput = tools.dataForKey(this.tableData[row.row], val)
  1070. this.myDialog.update = true
  1071. }
  1072. },
  1073. //关闭临时维护弹窗回调
  1074. handleCloseUpdate() {
  1075. this.updateInputShow = false
  1076. this.updateInfoPoint = ''
  1077. this.updateInput = ''
  1078. },
  1079. //更新临时维护信息点
  1080. handleClickUpdate() {
  1081. tools.setDataForKey(this.tableData[this.row], this.updateInfoPoint, this.updateInput)
  1082. this.handleUpdataTable([[this.row, this.updateInfoPoint, null, this.updateInput]], "edit")
  1083. this.updateInputShow = false
  1084. this.myDialog.update = false
  1085. this.updateInput = ''
  1086. },
  1087. //获取被筛选掉的行号
  1088. trimmedRows() {
  1089. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  1090. let dataLength = this.tableData.length;
  1091. let dataArr = new Array();
  1092. for (let i = 0; i < dataLength; i++) {
  1093. dataArr.push(i);
  1094. }
  1095. if (plugin.length <= 0) {
  1096. dataArr = undefined;
  1097. } else {
  1098. dataArr = this.array_diff(dataArr, plugin);
  1099. }
  1100. return dataArr || [];
  1101. },
  1102. //去除数组中相同的元素
  1103. array_diff(a, b) {
  1104. for (var i = 0; i < b.length; i++) {
  1105. for (var j = 0; j < a.length; j++) {
  1106. if (a[j] == b[i]) {
  1107. a.splice(j, 1);
  1108. j = j - 1;
  1109. }
  1110. }
  1111. }
  1112. return a;
  1113. },
  1114. //如果选择供应商之后
  1115. supplierChange(data, type) {
  1116. if (type === 'dialog') {
  1117. let firm = {...data, num: 8}
  1118. this.firmName = firm
  1119. } else {
  1120. tools.setDataForKey(this.tableData[this.row], "DPSupplierID", data.venderId)
  1121. tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.Supplier", data.name)
  1122. this.handleUpdataTable(
  1123. [
  1124. [this.row, "DPSupplierID", null, data.venderId],
  1125. [this.row, "LedgerParam.SupplyPurchase.Supplier", null, data.name]
  1126. ],
  1127. "edit"
  1128. )
  1129. // this.handleUpdataTable([[this.row, "LedgerParam.SupplyPurchase.Supplier", null, data.name]], "edit")
  1130. }
  1131. },
  1132. //供应合同编号
  1133. supplyChange(data) {
  1134. tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.SupplierContractID", {id: data})
  1135. },
  1136. //保险单号-保险文件
  1137. guaranteeChange(data) {
  1138. for (let key in data) {
  1139. this.utilToKey(key, "insuranceNo", data, "InsuranceNum")
  1140. if (key == "contractFile") {
  1141. if (!!data[key]) {
  1142. data[key] = [data[key]]
  1143. }
  1144. }
  1145. this.utilToKey(key, "contractFile", data, "InsuranceFile")
  1146. }
  1147. },
  1148. //选择型号修改
  1149. firmChange(data, type) {
  1150. if (type === 'dialog') { // 如果是批量信息维护
  1151. let venderName = data.venderName ? data.venderName : '空'
  1152. let brandName = data.brandName ? data.brandName : '空'
  1153. let name = data.name ? data.name : '空'
  1154. let firm = {
  1155. ...data,
  1156. num: 2,
  1157. Specification: data.name,
  1158. name: `${venderName}/${brandName}/${name}`
  1159. }
  1160. this.firmName = firm //批量维护dialog显示对象的字段
  1161. } else { //如果是表格操作
  1162. tools.setDataForKey(this.tableData[this.row], "DPManufacturerID", data.venderId)//生产商ID
  1163. tools.setDataForKey(this.tableData[this.row], "DPBrandID", data.brandId)//品牌ID
  1164. tools.setDataForKey(this.tableData[this.row], "DPSpecificationID", data.specificationId)//型号ID
  1165. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Manufacturer", data.venderName)
  1166. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Brand", data.brandName)
  1167. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Specification", data.name)
  1168. this.handleUpdataTable(
  1169. [
  1170. [this.row, "DPManufacturerID", null, data.venderId],
  1171. [this.row, "DPBrandID", null, data.brandId],
  1172. [this.row, "DPSpecificationID", null, data.specificationId],
  1173. [this.row, "LedgerParam.EquipManufactor.Manufacturer", null, data.venderName],
  1174. [this.row, "LedgerParam.EquipManufactor.Brand", null, data.brandName],
  1175. [this.row, "LedgerParam.EquipManufactor.Specification", null, data.name]
  1176. ],
  1177. "edit"
  1178. )
  1179. // this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Brand", null, data.brand]], "edit")
  1180. // this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Specification", null, data.name]], "edit")
  1181. }
  1182. },
  1183. //保险商变更
  1184. changeInsurer(data, type) {
  1185. if (type === 'dialog') {
  1186. let firm = {...data, num: 42}
  1187. this.firmName = firm
  1188. } else {
  1189. tools.setDataForKey(this.tableData[this.row], "DPInsurerID", data.venderId)
  1190. tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.Insurer", data.name)
  1191. this.handleUpdataTable(
  1192. [
  1193. [this.row, "DPInsurerID", null, data.venderId],
  1194. [this.row, "LedgerParam.InsuranceDoc.Insurer", null, data.name]
  1195. ],
  1196. "edit"
  1197. )
  1198. // this.handleUpdataTable([[this.row, "LedgerParam.InsuranceDoc.Insurer", null, data.name]], "edit")
  1199. }
  1200. },
  1201. //维修商变更
  1202. changeMaintainer(data, type) {
  1203. if (type === 'dialog') {
  1204. let firm = {...data, num: 35}
  1205. this.firmName = firm
  1206. } else {
  1207. tools.setDataForKey(this.tableData[this.row], "DPMaintainerID", data.venderId)
  1208. tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.Maintainer", data.name)
  1209. this.handleUpdataTable(
  1210. [
  1211. [this.row, "DPMaintainerID", null, data.venderId],
  1212. [this.row, "LedgerParam.OperationMainte.Maintainer", null, data.name]
  1213. ],
  1214. "edit"
  1215. )
  1216. // this.handleUpdataTable([[this.row, "LedgerParam.OperationMainte.Maintainer", null, data.name]], "edit")
  1217. }
  1218. },
  1219. //修改关联的资产
  1220. changeProperty(val) {
  1221. this.setDataToMain(val.PropertyId, 'PropertyId', this.row);
  1222. this.setDataToMain(val.LinkEquipLocalName, 'LinkEquipLocalName', this.row);
  1223. },
  1224. //上传文件弹窗触发事件
  1225. fileChange(keys, type) {
  1226. if (type === 'dialog') {
  1227. this.information = keys
  1228. } else {
  1229. this.setDataToMain(keys, this.messKey, this.row);
  1230. }
  1231. },
  1232. //上传图片弹窗触发事件
  1233. imgChange(keys, type) {
  1234. if (type === 'dialog') {
  1235. this.information = keys
  1236. } else {
  1237. this.setDataToMain(keys, this.messKey, this.row);
  1238. }
  1239. },
  1240. //关联系统更改
  1241. changeSystemType(data) {
  1242. tools.setDataForKey(this.tableData[this.row], "LinkSystem", data)
  1243. },
  1244. //设备图片弹窗改变事件
  1245. changePics(keys, type) {
  1246. if (type === 'dialog') {
  1247. this.information = keys
  1248. } else {
  1249. this.setDataToMain(keys, this.messKey, this.row);
  1250. }
  1251. },
  1252. utilToKey(key, name, data, messName) {
  1253. if (key == name) {
  1254. this.setDataToMain(data[key], messName, this.row)
  1255. }
  1256. },
  1257. //判断是否有值,有值赋值
  1258. setDataToMain(data, key, row) {
  1259. if (!!data && data != '--') {
  1260. if (!!this.tableData[row]) {
  1261. tools.setDataForKey(this.tableData[row], key, data);
  1262. this.handleUpdataTable([[row, key, null, data]], "edit");
  1263. } else {
  1264. this.tableData[row] = {};
  1265. tools.setDataForKey(this.tableData[row], key, data);
  1266. }
  1267. } else {
  1268. tools.setDataForKey(this.tableData[row], key, "");
  1269. }
  1270. },
  1271. // 批量信息维护
  1272. Batch() {
  1273. this.firmDataType = 'dialog'
  1274. this.$refs.batchDialogs.batchDialog = true
  1275. },
  1276. upDataDevice(type, data1, data2) {
  1277. let param = {Content: data1}
  1278. let param1 = {Content: data2}
  1279. if (type === 1) { //增量
  1280. //LedgerParam
  1281. let filterParam = this.filterCheck(param, 'sole')
  1282. let filterParam1 = this.filterCheck(param1, 'multiple')
  1283. if (filterParam) {
  1284. updateEquip(param, res => {
  1285. });
  1286. }
  1287. if (filterParam1) {
  1288. setTimeout(() => {
  1289. queryUpdate(param1, res => {
  1290. })
  1291. })
  1292. }
  1293. }
  1294. if (type === 2) {//覆盖
  1295. let filterParams = this.filterCheck(param, 'sole')
  1296. if (filterParams) {
  1297. updateEquip(param, res => {
  1298. });
  1299. }
  1300. }
  1301. setTimeout(() => {
  1302. this.getTableData()
  1303. this.getAllData()
  1304. }, 10)
  1305. },
  1306. filterCheck(arr, type) {
  1307. if (type === 'sole') {
  1308. for (let i of arr.Content) {
  1309. return Object.keys(i.LedgerParam).length
  1310. }
  1311. } else if (type === 'multiple') {
  1312. let nArr = [];
  1313. arr.Content.forEach(i => {
  1314. let {EquipID, ...value} = i
  1315. nArr.push({LedgerParam: value})
  1316. })
  1317. for (let j of nArr) {
  1318. return Object.keys(j.LedgerParam).length
  1319. }
  1320. }
  1321. }
  1322. },
  1323. watch: {
  1324. projectId() {
  1325. this.buildFloorData = []
  1326. buildFloor.getData(this.buildFloorData)
  1327. this.tableData = []
  1328. this.mess.deviceId = null
  1329. this.page.total = 0
  1330. },
  1331. showTypes: {
  1332. handler(newName, oldName) {
  1333. if (newName && newName[0] && newName[0].value) {
  1334. this.showType = newName[0].value
  1335. } else {
  1336. this.showType = ""
  1337. }
  1338. },
  1339. immediate: true,
  1340. deep: true
  1341. }
  1342. }
  1343. };
  1344. </script>
  1345. <style lang="less">
  1346. .hanson-bar {
  1347. height: 40px;
  1348. padding: 5px 0;
  1349. font-size: 14px;
  1350. overflow: hidden;
  1351. margin-top: 0;
  1352. line-height: 40px;
  1353. .iconfont {
  1354. font-size: 12px;
  1355. }
  1356. }
  1357. .cancelButtonClass {
  1358. width: 180px;
  1359. }
  1360. </style>