device.vue 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428
  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. case 'LedgerParam.OperationMainte.MaintainManual': //维修保养手册
  1067. case 'LedgerParam.SupplyPurchase.ApproachingAcceptance': //进场验收单
  1068. case 'LedgerParam.SupplyPurchase.AcceptanceReport': //验收报告
  1069. case 'LedgerParam.PhotoDoc.OperationManual': //操作说明书
  1070. case 'LedgerParam.EquipManufactor.OriginalCertificate': //原厂证明
  1071. case 'LedgerParam.EquipManufactor.TestReport': //检测报告
  1072. case 'LedgerParam.PhotoDoc.ProductCertification': //产品合格证
  1073. case 'LedgerParam.Siteinstall.InstallInstruction': //安装说明书
  1074. case 'LedgerParam.PhotoDoc.Drawing': //设备图纸
  1075. case 'LedgerParam.Siteinstall.InstallDrawing': //安装图纸
  1076. let IPSdata = tools.dataForKey(this.tableData[row.row], val);
  1077. this.filesArr = IPSdata ? IPSdata : [];
  1078. if (!this.onlyRead || this.filesArr.length) {
  1079. this.myDialog.uploadFiles = true;
  1080. }
  1081. return false
  1082. //安装照片--设备铭牌照片
  1083. case 'LedgerParam.Siteinstall.InstallPic':
  1084. case 'LedgerParam.PhotoDoc.Nameplate':
  1085. let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
  1086. this.imgsArr = SSPPdata ? SSPPdata : [];
  1087. if (!this.onlyRead || this.imgsArr.length) {
  1088. this.myDialog.uploadImgs = true;
  1089. }
  1090. return false
  1091. //设备照片
  1092. case 'LedgerParam.PhotoDoc.Pic':
  1093. let Pdata = tools.dataForKey(this.tableData[row.row], val);
  1094. this.picsArr = Pdata ? Pdata : [];
  1095. if (!this.onlyRead || this.picsArr.length) {
  1096. this.myDialog.pic = true;
  1097. }
  1098. return false
  1099. //包含的部件字段
  1100. case 'Count':
  1101. let countUrl = this.onlyRead ? '/ledger/parts' : '/ledger/partsmanage';
  1102. this.$router.push({path: countUrl, query: {
  1103. deviceId: infos.EquipID,
  1104. typeId: this.mess.deviceId,
  1105. pageNo: this.page.currentPage,
  1106. pageSize: this.page.size
  1107. }});
  1108. return false
  1109. default:
  1110. break;
  1111. }
  1112. if (!this.onlyRead && showTools.InputModeArr.indexOf(inputMode) == '-1') {
  1113. this.updateInfoPoint = val
  1114. this.updateInput = tools.dataForKey(this.tableData[row.row], val)
  1115. this.myDialog.update = true
  1116. }
  1117. },
  1118. //关闭临时维护弹窗回调
  1119. handleCloseUpdate() {
  1120. this.updateInputShow = false
  1121. this.updateInfoPoint = ''
  1122. this.updateInput = ''
  1123. },
  1124. //更新临时维护信息点
  1125. handleClickUpdate() {
  1126. tools.setDataForKey(this.tableData[this.row], this.updateInfoPoint, this.updateInput)
  1127. this.handleUpdataTable([[this.row, this.updateInfoPoint, null, this.updateInput]], "edit")
  1128. this.updateInputShow = false
  1129. this.myDialog.update = false
  1130. this.updateInput = ''
  1131. },
  1132. //获取被筛选掉的行号
  1133. trimmedRows() {
  1134. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  1135. let dataLength = this.tableData.length;
  1136. let dataArr = new Array();
  1137. for (let i = 0; i < dataLength; i++) {
  1138. dataArr.push(i);
  1139. }
  1140. if (plugin.length <= 0) {
  1141. dataArr = undefined;
  1142. } else {
  1143. dataArr = this.array_diff(dataArr, plugin);
  1144. }
  1145. return dataArr || [];
  1146. },
  1147. //去除数组中相同的元素
  1148. array_diff(a, b) {
  1149. for (var i = 0; i < b.length; i++) {
  1150. for (var j = 0; j < a.length; j++) {
  1151. if (a[j] == b[i]) {
  1152. a.splice(j, 1);
  1153. j = j - 1;
  1154. }
  1155. }
  1156. }
  1157. return a;
  1158. },
  1159. //如果选择供应商之后
  1160. supplierChange(data, type) {
  1161. if (type === 'dialog') {
  1162. let firm = {...data, num: 8}
  1163. this.firmName = firm
  1164. } else {
  1165. tools.setDataForKey(this.tableData[this.row], "DPSupplierID", data.venderId)
  1166. tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.Supplier", data.name)
  1167. this.handleUpdataTable(
  1168. [
  1169. [this.row, "DPSupplierID", null, data.venderId],
  1170. [this.row, "LedgerParam.SupplyPurchase.Supplier", null, data.name]
  1171. ],
  1172. "edit"
  1173. )
  1174. // this.handleUpdataTable([[this.row, "LedgerParam.SupplyPurchase.Supplier", null, data.name]], "edit")
  1175. }
  1176. },
  1177. //供应合同编号
  1178. supplyChange(data) {
  1179. tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.SupplierContractID", {id: data})
  1180. },
  1181. //保险单号-保险文件
  1182. guaranteeChange(data) {
  1183. for (let key in data) {
  1184. this.utilToKey(key, "insuranceNo", data, "InsuranceNum")
  1185. if (key == "contractFile") {
  1186. if (!!data[key]) {
  1187. data[key] = [data[key]]
  1188. }
  1189. }
  1190. this.utilToKey(key, "contractFile", data, "InsuranceFile")
  1191. }
  1192. },
  1193. //选择型号修改
  1194. firmChange(data, type) {
  1195. if (type === 'dialog') { // 如果是批量信息维护
  1196. let venderName = data.venderName ? data.venderName : '空'
  1197. let brandName = data.brandName ? data.brandName : '空'
  1198. let name = data.name ? data.name : '空'
  1199. let firm = {
  1200. ...data,
  1201. num: 2,
  1202. Specification: data.name,
  1203. name: `${venderName}/${brandName}/${name}`
  1204. }
  1205. this.firmName = firm //批量维护dialog显示对象的字段
  1206. } else { //如果是表格操作
  1207. tools.setDataForKey(this.tableData[this.row], "DPManufacturerID", data.venderId)//生产商ID
  1208. tools.setDataForKey(this.tableData[this.row], "DPBrandID", data.brandId)//品牌ID
  1209. tools.setDataForKey(this.tableData[this.row], "DPSpecificationID", data.specificationId)//型号ID
  1210. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Manufacturer", data.venderName)
  1211. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Brand", data.brandName)
  1212. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Specification", data.name)
  1213. this.handleUpdataTable(
  1214. [
  1215. [this.row, "DPManufacturerID", null, data.venderId],
  1216. [this.row, "DPBrandID", null, data.brandId],
  1217. [this.row, "DPSpecificationID", null, data.specificationId],
  1218. [this.row, "LedgerParam.EquipManufactor.Manufacturer", null, data.venderName],
  1219. [this.row, "LedgerParam.EquipManufactor.Brand", null, data.brandName],
  1220. [this.row, "LedgerParam.EquipManufactor.Specification", null, data.name]
  1221. ],
  1222. "edit"
  1223. )
  1224. // this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Brand", null, data.brand]], "edit")
  1225. // this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Specification", null, data.name]], "edit")
  1226. }
  1227. },
  1228. //保险商变更
  1229. changeInsurer(data, type) {
  1230. if (type === 'dialog') {
  1231. let firm = {...data, num: 42}
  1232. this.firmName = firm
  1233. } else {
  1234. tools.setDataForKey(this.tableData[this.row], "DPInsurerID", data.venderId)
  1235. tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.Insurer", data.name)
  1236. this.handleUpdataTable(
  1237. [
  1238. [this.row, "DPInsurerID", null, data.venderId],
  1239. [this.row, "LedgerParam.InsuranceDoc.Insurer", null, data.name]
  1240. ],
  1241. "edit"
  1242. )
  1243. // this.handleUpdataTable([[this.row, "LedgerParam.InsuranceDoc.Insurer", null, data.name]], "edit")
  1244. }
  1245. },
  1246. //维修商变更
  1247. changeMaintainer(data, type) {
  1248. if (type === 'dialog') {
  1249. let firm = {...data, num: 35}
  1250. this.firmName = firm
  1251. } else {
  1252. tools.setDataForKey(this.tableData[this.row], "DPMaintainerID", data.venderId)
  1253. tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.Maintainer", data.name)
  1254. this.handleUpdataTable(
  1255. [
  1256. [this.row, "DPMaintainerID", null, data.venderId],
  1257. [this.row, "LedgerParam.OperationMainte.Maintainer", null, data.name]
  1258. ],
  1259. "edit"
  1260. )
  1261. // this.handleUpdataTable([[this.row, "LedgerParam.OperationMainte.Maintainer", null, data.name]], "edit")
  1262. }
  1263. },
  1264. //修改关联的资产
  1265. changeProperty(val) {
  1266. this.setDataToMain(val.PropertyId, 'PropertyId', this.row);
  1267. this.setDataToMain(val.LinkEquipLocalName, 'LinkEquipLocalName', this.row);
  1268. },
  1269. //上传文件弹窗触发事件
  1270. fileChange(keys, type) {
  1271. if (type === 'dialog') {
  1272. this.information = keys
  1273. } else {
  1274. this.setDataToMain(keys, this.messKey, this.row);
  1275. }
  1276. },
  1277. //上传图片弹窗触发事件
  1278. imgChange(keys, type) {
  1279. if (type === 'dialog') {
  1280. this.information = keys
  1281. } else {
  1282. this.setDataToMain(keys, this.messKey, this.row);
  1283. }
  1284. },
  1285. //关联系统更改
  1286. changeSystemType(data) {
  1287. tools.setDataForKey(this.tableData[this.row], "LinkSystem", data)
  1288. },
  1289. //设备图片弹窗改变事件
  1290. changePics(keys, type) {
  1291. if (type === 'dialog') {
  1292. this.information = keys
  1293. } else {
  1294. this.setDataToMain(keys, this.messKey, this.row);
  1295. }
  1296. },
  1297. utilToKey(key, name, data, messName) {
  1298. if (key == name) {
  1299. this.setDataToMain(data[key], messName, this.row)
  1300. }
  1301. },
  1302. //判断是否有值,有值赋值
  1303. setDataToMain(data, key, row) {
  1304. if (!!data && data != '--') {
  1305. if (!!this.tableData[row]) {
  1306. tools.setDataForKey(this.tableData[row], key, data);
  1307. this.handleUpdataTable([[row, key, null, data]], "edit");
  1308. } else {
  1309. this.tableData[row] = {};
  1310. tools.setDataForKey(this.tableData[row], key, data);
  1311. }
  1312. } else {
  1313. tools.setDataForKey(this.tableData[row], key, "");
  1314. }
  1315. },
  1316. // 批量信息维护
  1317. Batch() {
  1318. this.firmDataType = 'dialog'
  1319. this.$refs.batchDialogs.batchDialog = true
  1320. },
  1321. upDataDevice(type, data1, data2) {
  1322. let param = {Content: data1}
  1323. let param1 = {Content: data2}
  1324. if (type === 1) { //增量
  1325. //LedgerParam
  1326. let filterParam = this.filterCheck(param, 'sole')
  1327. let filterParam1 = this.filterCheck(param1, 'multiple')
  1328. if (filterParam) {
  1329. updateEquip(param, res => {
  1330. });
  1331. }
  1332. if (filterParam1) {
  1333. setTimeout(() => {
  1334. queryUpdate(param1, res => {
  1335. })
  1336. })
  1337. }
  1338. }
  1339. if (type === 2) {//覆盖
  1340. let filterParams = this.filterCheck(param, 'sole')
  1341. if (filterParams) {
  1342. updateEquip(param, res => {
  1343. });
  1344. }
  1345. }
  1346. setTimeout(() => {
  1347. this.getTableData()
  1348. this.getAllData()
  1349. }, 10)
  1350. },
  1351. filterCheck(arr, type) {
  1352. if (type === 'sole') {
  1353. for (let i of arr.Content) {
  1354. return Object.keys(i.LedgerParam).length
  1355. }
  1356. } else if (type === 'multiple') {
  1357. let nArr = [];
  1358. arr.Content.forEach(i => {
  1359. let {EquipID, ...value} = i
  1360. nArr.push({LedgerParam: value})
  1361. })
  1362. for (let j of nArr) {
  1363. return Object.keys(j.LedgerParam).length
  1364. }
  1365. }
  1366. }
  1367. },
  1368. watch: {
  1369. projectId() {
  1370. this.buildFloorData = []
  1371. buildFloor.getData(this.buildFloorData)
  1372. this.tableData = []
  1373. this.mess.deviceId = null
  1374. this.page.total = 0
  1375. },
  1376. showTypes: {
  1377. handler(newName, oldName) {
  1378. if (newName && newName[0] && newName[0].value) {
  1379. this.showType = newName[0].value
  1380. } else {
  1381. this.showType = ""
  1382. }
  1383. },
  1384. immediate: true,
  1385. deep: true
  1386. }
  1387. }
  1388. };
  1389. </script>
  1390. <style lang="less">
  1391. .hanson-bar {
  1392. height: 40px;
  1393. padding: 5px 0;
  1394. font-size: 14px;
  1395. overflow: hidden;
  1396. margin-top: 0;
  1397. line-height: 40px;
  1398. .iconfont {
  1399. font-size: 12px;
  1400. }
  1401. }
  1402. .cancelButtonClass {
  1403. width: 180px;
  1404. }
  1405. </style>