device.vue 51 KB

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