device.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  1. <template>
  2. <div>
  3. <div class="hanson-bar">
  4. <span
  5. style="width:20px;float:left;display:block;height:20px;cursor: pointer;"
  6. @click="changeAssetsFalg"
  7. >
  8. <i class="iconfont icon-xiaolian"></i>
  9. </span>
  10. <span>当前筛选条件下共{{page.total || '--'}}设备</span>
  11. <div style="width:390px;float:right;overflow:hidden;">
  12. <el-button size="small" style='width: 80px;' @click="download" icon="iconfont icon-xiazai">下载</el-button>
  13. <el-button size="small" style='width: 80px;' @click="addDevice" icon="iconfont icon-tianjia">添加设备</el-button>
  14. <el-button size="small" style='width: 80px;' @click="reset" icon="iconfont icon-shuaxin">刷新</el-button>
  15. <el-button size="small" style='width: 80px;' @click="undo" icon="iconfont icon-undo">撤销</el-button>
  16. </div>
  17. <div style="width:200px;color:gray;float:right;font-size:10px;">
  18. <span v-if="!onlyRead">隐藏自动填充的信息点:</span>
  19. <el-tooltip v-if="!onlyRead" :content="'' + (isWatch ? '隐藏' : '不隐藏')" placement="top">
  20. <el-switch
  21. @change="changeWatch"
  22. v-model="isWatch"
  23. active-color="#13ce66"
  24. inactive-color="gray"
  25. ></el-switch>
  26. </el-tooltip>
  27. <span v-if="onlyRead">只看要采集的信息:</span>
  28. <el-tooltip v-if="onlyRead" :content="'' + (allMess ? '部分' : '全集')" placement="top">
  29. <el-switch
  30. @change="changeWatch"
  31. v-model="allMess"
  32. active-color="#13ce66"
  33. inactive-color="gray"
  34. ></el-switch>
  35. </el-tooltip>
  36. </div>
  37. <div
  38. style="width:90px;cursor: pointer;color:gray;float:right; font-size:10px;"
  39. >
  40. <p v-if="onlyRead" @click="changeRead">
  41. <i class="iconfont icon-yulan"></i>
  42. <span>只读模式</span>
  43. </p>
  44. <p v-else @click="changeRead">
  45. <i class="iconfont icon-yulan"></i>
  46. <span>编辑模式</span>
  47. </p>
  48. </div>
  49. </div>
  50. <!-- 二维码弹窗 -->
  51. <qrcode :dialog="dialog" :qrcodeUrl="qrcodeUrl" :addBody="true" ref="qrcode"></qrcode>
  52. <!-- 型号弹窗 -->
  53. <firm :mess="{deviceId: deviceType.code}" ref="firm" @changeFirm="firmChange" :dialog="dialog"></firm>
  54. <!-- 供应商合同弹窗 -->
  55. <supply-dialog ref="supply" @change="supplyChange" :id="id" :dialog="dialog"></supply-dialog>
  56. <!-- 供应商弹窗 -->
  57. <supplier-dialog ref="supplier" @changeSupplier="supplierChange" :dialog="dialog"></supplier-dialog>
  58. <guarantee-dialog :id="id" ref="guarantee" @change="guaranteeChange" :dialog="dialog"></guarantee-dialog>
  59. <upload-files-dialog
  60. :read="onlyRead ? true : false"
  61. ref="upload"
  62. @changeFile="fileChange"
  63. :keysArr="filesArr"
  64. :dialog="dialog"
  65. ></upload-files-dialog>
  66. <upload-img-dialog
  67. :read="onlyRead ? true : false"
  68. @changeFile="imgChange"
  69. :keysArr="imgsArr"
  70. :dialog="dialog"
  71. ></upload-img-dialog>
  72. <maintainer-dialog @changeMaintainer="changeMaintainer" ref="maintainer" :dialog="dialog"></maintainer-dialog>
  73. <insurer-dialog @changeInsurer="changeInsurer" ref="insurer" :dialog="dialog"></insurer-dialog>
  74. <pic-dialog
  75. :read="onlyRead ? true : false"
  76. :dialog="dialog"
  77. :keysArr="picsArr"
  78. @change="changePics"
  79. ></pic-dialog>
  80. <system-type :infos="systemId" :graphyId="graphyId" :dialog="dialog"></system-type>
  81. <div
  82. v-show="!main || !main.length"
  83. style="width:100%;text-align:center;font-size:30px;color:gray;"
  84. >{{ mess.deviceId ? '请选择设备族' : '无设备'}}</div>
  85. <div v-show="main && main.length" v-loading="loading" id="handsontable" ref="handsontable"></div>
  86. <div v-show="main && main.length" class="right">
  87. <my-pagination @change="getMain" :page="page"></my-pagination>
  88. </div>
  89. <dialog-assets
  90. @close="getClose"
  91. :graphyId="graphyId"
  92. :assetType="[this.mess.deviceId]"
  93. ref="assets"
  94. :dialog="dialog"
  95. ></dialog-assets>
  96. <details-dialog :iframeSrc="iframeSrc" v-if="dialog.details" :dialog="dialog"></details-dialog>
  97. <change-rea @close="reset" :dialog="dialog" :category="category"></change-rea>
  98. <look-pic :dialog="dialog" :keysArr="picsArr"></look-pic>
  99. </div>
  100. </template>
  101. <script>
  102. import { getTableHeader, getSpaceFloor, getEquipmentFamily, getBillEquipList, BeatchQueryParam, delBatchList, updateBusiness } from "@/api/scan/request";
  103. import tools from "@/utils/scan/tools";
  104. import handsonUtils from "@/utils/hasontableUtils"
  105. import showTools from "@/utils/handsontable/notShow"
  106. import text from "@/utils/handsontable/mainText"
  107. import qrcode from "@/components/ledger/lib/qrcode";
  108. import firm from "@/components/dialogs/list/firm";
  109. import supplyDialog from "@/components/dialogs/list/supplyDialog";
  110. import supplierDialog from "@/components/dialogs/list/supplierDialog";
  111. import maintainerDialog from "@/components/dialogs/list/maintainerDialog";
  112. import insurerDialog from "@/components/dialogs/list/insurerDialog";
  113. import guaranteeDialog from "@/components/dialogs/list/guaranteeDialog";
  114. import uploadFilesDialog from "@/components/dialogs/list/filesDialog";
  115. import uploadImgDialog from "@/components/dialogs/list/uploadImgDialog";
  116. import picDialog from "@/components/dialogs/list/picDialog"
  117. import systemType from "@/components/dialogs/list/systemType"
  118. import myPagination from "@/components/ledger/lib/myPagination";
  119. import dialogAssets from "@/components/dialogs/addDialog/dialogDevice";
  120. import detailsDialog from "@/components/ledger/lib/detailsDia"
  121. import changeRea from "@/components/dialogs/changeRea"
  122. //图片查看
  123. import lookPic from "@/components/ledger/lib/lookImages"
  124. //下拉插件
  125. import "@/assets/js/chosen.jquery.min";
  126. import "@/assets/js/handsontable-chosen-editor";
  127. import {mapGetters, mapActions} from "vuex";
  128. import Handsontable from "handsontable-pro"
  129. import 'handsontable-pro/dist/handsontable.full.css'
  130. import zhCN from 'handsontable-pro/languages/zh-CN';
  131. export default {
  132. props: ["myParam"],
  133. components: {
  134. qrcode, //二维码页面
  135. firm, //
  136. supplyDialog,
  137. supplierDialog,
  138. guaranteeDialog,
  139. uploadFilesDialog,
  140. maintainerDialog,
  141. insurerDialog,
  142. uploadImgDialog,
  143. picDialog,
  144. myPagination,
  145. dialogAssets,
  146. systemType,
  147. detailsDialog,
  148. changeRea,
  149. lookPic
  150. },
  151. data() {
  152. return {
  153. main: [],
  154. mess: {},
  155. headers: null,
  156. page: {
  157. size: 50,
  158. sizes: [10, 30, 50, 100, 150, 200],
  159. total: 0,
  160. currentPage: 1
  161. },
  162. dialog: {
  163. qrcode: false, //二维码弹窗
  164. firm: false, //厂商弹窗
  165. supply: false, //选择供应合同
  166. supplier: false, //供应商选择
  167. guarantee: false, //选择保单
  168. maintainer: false, //选择维修商
  169. insurer: false, //选择保险公司
  170. uploadFiles: false,//上传文件
  171. uploadImgs: false,//上传单个图片
  172. pic: false, //多个图片
  173. addDevice: false,
  174. systemType: false,
  175. details: false,//详情页
  176. changeRea: false,
  177. lookPic: false,//图片查看
  178. },
  179. row: null,//被修改的row
  180. filesArr: [],//保存临时的文件key
  181. messKey: null,
  182. imgsArr: [],//临时保存的图片key数组
  183. picsArr: [],//临时设备图片keys数组
  184. projId: "",
  185. copyMain: null,
  186. graphyId: null,
  187. systemId: null,
  188. assetGroupList: [],
  189. iframeSrc: "",
  190. id: 0,
  191. isWatch: true,
  192. category: {},
  193. onlyRead: true,
  194. allMess: true,
  195. linkNameFalg: false,
  196. qrcodeUrl: "",//二维码图片地址
  197. loading: false,
  198. EquipmentList: [],//资产族
  199. deviceType: {},
  200. floorData: []
  201. };
  202. },
  203. created() {
  204. this.getEquipmentFamilyList()
  205. this.getFloorData()
  206. },
  207. computed: {
  208. ...mapGetters("peojMess", [
  209. "projectId",
  210. "secret",
  211. "userId"
  212. ])
  213. },
  214. methods: {
  215. //获取楼层数据
  216. getFloorData() {
  217. let param = {
  218. ProjId: this.projectId,
  219. secret: this.secret
  220. }
  221. getSpaceFloor(param).then(res => {
  222. if (res.data.Result == 'success') {
  223. let data = this.changeArr(res.data.Content), floorData = []
  224. data.map(item => {
  225. if (!!item.children) {
  226. item.children.unshift({
  227. value: '',
  228. label: "未明确楼层"
  229. })
  230. }
  231. return item
  232. })
  233. data.map(item => {
  234. if (!!item.children && item.children.length) {
  235. item.children.map(child => {
  236. floorData.push({
  237. Code: item.value + "-" + child.value,
  238. Name: item.label + "-" + child.label
  239. })
  240. })
  241. }
  242. })
  243. this.floorData = floorData
  244. } else {
  245. this.$message.error(res.data.ResultMsg)
  246. }
  247. }).catch(() => {
  248. this.$message.error("请求出错")
  249. })
  250. },
  251. //将数组转换成optiosn格式
  252. changeArr(arr) {
  253. return arr.map(item => {
  254. if (item.floors && item.floors.length) {
  255. return {
  256. value: item.id,
  257. label: item.infos.BuildLocalName,
  258. children: item.floors.map(i => {
  259. return {
  260. value: i.id,
  261. label: i.infos.FloorLocalName || "未知",
  262. }
  263. })
  264. }
  265. } else {
  266. return {
  267. value: item.id,
  268. label: item.infos.BuildLocalName,
  269. children: null,
  270. isChilren: 1,
  271. }
  272. }
  273. })
  274. },
  275. changeRead() {
  276. this.onlyRead = !this.onlyRead
  277. this.getMain()
  278. },
  279. getEquipmentFamilyList() {
  280. getEquipmentFamily(res => {
  281. this.EquipmentList = res.Content
  282. })
  283. },
  284. //触发父组件change
  285. getClose(val) {
  286. this.$emit("close", val)
  287. },
  288. setGraphyId(graphyId, assetGroupList) {
  289. this.graphyId = graphyId
  290. this.assetGroupList = assetGroupList
  291. },
  292. //获取表头
  293. getHeaderData(code) {
  294. this.page.currentPage = 1
  295. this.mess = code
  296. this.changeCader()
  297. if(this.mess.deviceId){
  298. getTableHeader({
  299. code: this.mess.deviceId,
  300. ProjId: this.projectId
  301. }).then(res => {
  302. this.headers = res.data.Content;
  303. this.getMain()
  304. });
  305. }
  306. },
  307. //获取主体数据
  308. getMain() {
  309. let _this = this
  310. this.loading = true
  311. let param = {
  312. data: {
  313. customInfo: true,
  314. "limit": { // 分页查询, 选填.
  315. "skip": this.page.size * (this.page.currentPage - 1), // 跳过多少数据
  316. "count": this.page.size // 查询跳过300条数据之后的50条 (默认按照创建时间从大-->小排序)
  317. },
  318. id: "",
  319. type: [this.mess.deviceId]
  320. },
  321. secret: this.secret,
  322. ProjId: this.projectId
  323. }
  324. if (this.mess.buildId == "all") {
  325. param.data.id = this.mess.ProjId
  326. } else if (this.mess.buildId == "noKnow") {
  327. param.data.id = this.mess.ProjId
  328. param.data.direct = true
  329. } else if (this.mess.floorId == "noKnow") {
  330. param.data.id = this.mess.buildId
  331. param.data.direct = true
  332. } else if (this.mess.floorId && this.mess.floorId != "all") {
  333. param.data.id = this.mess.floorId
  334. } else if (this.mess.floorId == 'all') {
  335. param.data.id = this.mess.buildId
  336. } else {
  337. param.data.id = this.mess.ProjId
  338. }
  339. //type存在发送请求
  340. if (!!this.mess.deviceId) {
  341. getBillEquipList(param, res => {
  342. if (res.Result == "success") {
  343. this.loading = false
  344. res.Content = res.Content.map(item => {
  345. item.linkName = item.linkEquipLocalName || item.linkEquipName
  346. if (!!item.linkFamily) {
  347. this.assetGroupList.map(child => {
  348. if (item.linkFamily == child.code) {
  349. item.linkFamily = child.name
  350. }
  351. })
  352. }
  353. if (!!item.infos.DPManufacturerID) {
  354. item.infos.DPManufacturerID = item.infos.DPManufacturerID + "-" + item.infos.Brand + "/" + item.infos.Specification
  355. }
  356. if (!!item.infos.DPSupplierID) {
  357. item.infos.DPSupplierID = item.infos.DPSupplierID + "-" + item.infos.Supplier
  358. }
  359. if (!!item.infos.DPMaintainerID) {
  360. item.infos.DPMaintainerID = item.infos.DPMaintainerID + "-" + item.infos.Maintainer
  361. }
  362. if (!!item.infos.DPInsurerID) {
  363. item.infos.DPInsurerID = item.infos.DPInsurerID + "-" + item.infos.Insurer
  364. }
  365. return item
  366. })
  367. if (_this.onlyRead) {
  368. this.getBatch(res.Content)
  369. }
  370. _this.main = res.Content
  371. _this.copyMain = tools.deepCopy(res.Content)
  372. _this.page.total = res.TotalCount
  373. if (!!_this.hot) {
  374. _this.hot.destroy();
  375. _this.hot = null;
  376. }
  377. if (!!res.Content && res.Content.length) {
  378. _this.initHot();
  379. }
  380. } else {
  381. this.loading = false
  382. this.$message.error("请求错误:" + res.ResultMsg)
  383. }
  384. })
  385. }
  386. },
  387. //获取动态参数
  388. getBatch(data) {
  389. let param = {
  390. secret: this.secret,
  391. ProjId: this.projectId,
  392. data: {
  393. criterias: []
  394. }
  395. }
  396. if (!!data && data.length) {
  397. //一级遍历list
  398. data.map(item => {
  399. if (!!item.infos) {
  400. // 二级遍历对象infos
  401. for (let key in item.infos) {
  402. //判断是否是设定参数和动态参数
  403. if (!!item.infos[key]) {
  404. this.headers.map(child => {
  405. //如果一级标签为动态参数或者设定参数放入数据等待请求
  406. if (key == child.InfoPointCode && (child.InputMode == "L" || child.InputMode == "L1" || child.InputMode == "L2")) {
  407. param.data.criterias.push({
  408. id: item.id,
  409. code: key
  410. })
  411. }
  412. })
  413. }
  414. }
  415. }
  416. })
  417. if (param.data.criterias.length) {
  418. BeatchQueryParam(param, res => {
  419. if (!this.onlyRead) {
  420. return false
  421. }
  422. this.main = data.map(item => {
  423. res.Content.map(child => {
  424. if (item.id == child.id) {
  425. if (!!child.data || child.data == 0) {
  426. item.infos[child.code] = child.data
  427. } else {
  428. item.infos[child.code] = child.error ? "表号功能号格式错误" : "表号功能号不存在"
  429. }
  430. }
  431. })
  432. return item
  433. })
  434. this.hot.loadData(this.main)
  435. })
  436. }
  437. }
  438. },
  439. changeAssetsFalg() {
  440. if (this.linkNameFalg) {
  441. this.linkNameFalg = false
  442. } else {
  443. this.$confirm('<p>真的要在这里修改设备关联的资产么?</p><p>真的能通过列表信息找到想关联的资产么?</p><p>在这里修改关联的资产一定是因为之前关联错了要修改么?</p>', '提示', {
  444. dangerouslyUseHTMLString: true,
  445. confirmButtonText: '没错!我要改关联的资产',
  446. cancelButtonText: '我就点开看看'
  447. }).then(_ => {
  448. this.linkNameFalg = true
  449. }).catch(_ => {
  450. this.$message("取消")
  451. })
  452. }
  453. },
  454. //switch改变
  455. changeWatch() {
  456. this.reset()
  457. },
  458. //撤回
  459. undo() {
  460. this.hot.undo();
  461. },
  462. //刷新
  463. reset() {
  464. this.getMain();
  465. },
  466. //添加设备
  467. addDevice() {
  468. this.dialog.addDevice = true
  469. this.$nextTick(() => {
  470. this.$refs.assets.step(0)
  471. })
  472. },
  473. //下载
  474. download() {
  475. if (!this.onlyRead) {
  476. if (!!this.hot) {
  477. let fileName = this.mess.name + "-页数:" + this.page.currentPage + "-个数:" + this.main.length + "-总个数:" + this.page.total
  478. this.hot.getPlugin('exportFile').downloadFile("csv", { filename: fileName, columnHeaders: true, exportHiddenRows: true, exportHiddenColumns: true, rowHeaders: true })
  479. } else {
  480. this.$message("请确定存在表格")
  481. }
  482. } else {
  483. this.$message("下载需在编辑状态下")
  484. }
  485. },
  486. /**
  487. * 表头文案处理函数
  488. * @param list header数组数据
  489. *
  490. * @return 处理好的文案
  491. */
  492. delHeader(list) {
  493. let arr = tools.copyArr(list)
  494. // 如果不是只读状态,添加四大厂商选择
  495. if (!this.onlyRead) {
  496. // arr = showTools.arrToArr(arr)
  497. }
  498. let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "X", "L", "L1", "L2", "F1", "F2"]
  499. if (!this.onlyRead) {
  500. readArr.push("Own")
  501. }
  502. let data = showTools.changeHeader(arr, readArr, this.onlyRead, this.isWatch, this.allMess)
  503. data.unshift("操作", "当前关联的资产", "所属系统实例");
  504. return data;
  505. },
  506. /**
  507. * 表头数据处理函数
  508. * @param list header数组数据
  509. *
  510. * @return 处理好的数据格式
  511. */
  512. getType(list) {
  513. let arr = tools.copyArr(list)
  514. // 如果不是只读状态,添加四大厂商选择
  515. if (!this.onlyRead) {
  516. // arr = showTools.arrToArr(arr)
  517. }
  518. let data = showTools.showTypes(arr, this.onlyRead, this.isWatch, this.allMess)
  519. data.map(item => {
  520. if (
  521. item.data == "infos." + "Drawing" ||
  522. item.data == "infos." + "Pic" ||
  523. item.data == "infos." + "Nameplate" ||
  524. item.data == "infos." + "InstallPic" ||
  525. item.data == "infos." + "InstallDrawing"
  526. ) {
  527. item.renderer = text.picType
  528. }
  529. if (item.data == "infos." + "Archive" ||
  530. item.data == "infos." + "CheckReport" ||
  531. item.data == "infos." + "InsuranceFile") {
  532. item.renderer = text.fileType
  533. }
  534. })
  535. data.unshift(
  536. {
  537. data: "caozuo",
  538. renderer: tools.lookDetails,
  539. readOnly: true
  540. },
  541. {
  542. data: "linkName",
  543. readOnly: true
  544. }, {
  545. data: "linkSystem",
  546. renderer: text.systemList,
  547. readOnly: true
  548. }
  549. );
  550. // data.splice(1, 0, {
  551. // data: "flowBuild",
  552. // renderer: tools.customDropdownRenderer,
  553. // editor: "chosen",
  554. // chosenOptions: {
  555. // // multiple: true,//多选
  556. // data: this.floorData
  557. // }
  558. // })
  559. if (!!this.onlyRead) {
  560. data.map(item => {
  561. item.readOnly = true
  562. })
  563. }
  564. return data;
  565. },
  566. messShow(item) {
  567. //二维码
  568. if (item.infopoint_code == "EquipQRCode") {
  569. return {
  570. data: "infos." + item.infopoint_code,
  571. renderer: text.lookQRCode,
  572. readOnly: true
  573. }
  574. }
  575. if (item.collection_cmpt_code == "Enum") {
  576. return {
  577. data: "infos." + item.infopoint_code,
  578. renderer: this.customDropdownRenderer,
  579. editor: "chosen",
  580. chosenOptions: {
  581. // multiple: true,//多选
  582. data: item.dataSource || ""
  583. }
  584. };
  585. } else if (item.collection_cmpt_code == "Num") {
  586. return {
  587. data: "infos." + item.infopoint_code,
  588. type: "numeric",
  589. numericFormat: {
  590. pattern: "0,0.00"
  591. // culture: 'de-DE' // use this for EUR (German),
  592. // more cultures available on http://numbrojs.com/languages.html
  593. }
  594. };
  595. } else if (item.collection_cmpt_code == "Time") {
  596. return {
  597. data: "infos." + item.infopoint_code,
  598. type: "date",
  599. dateFormat: "YYYY-MM-DD",
  600. correctFormat: true
  601. };
  602. } else if (item.collection_cmpt_code == "text") {
  603. return {
  604. data: "infos." + item.infopoint_code
  605. };
  606. } else if (
  607. (item.info_point_code == "设备ID" ||
  608. item.info_point_code == "设备名称")
  609. ) {
  610. return {
  611. data: "infos." + item.infopoint_code,
  612. readOnly: true
  613. };
  614. } else if (item.collection_cmpt_code == "checkBox") {
  615. return {
  616. data: "infos." + item.infopoint_code,
  617. renderer: this.customDropdownRenderer,
  618. editor: "chosen",
  619. chosenOptions: {
  620. multiple: true,//多选
  621. data: item.dataSource || ""
  622. }
  623. };
  624. } else {
  625. return {
  626. data: "infos." + item.infopoint_code,
  627. }
  628. }
  629. },
  630. changeItem(item) {
  631. //二维码
  632. if (item.infopoint_code == "EquipQRCode" && item.visible) {
  633. return {
  634. data: "infos." + item.infopoint_code,
  635. renderer: text.lookQRCode,
  636. readOnly: true
  637. }
  638. }
  639. //厂商选择
  640. // if ((item.infopoint_code == "Brand" || item.infopoint_code == "Specification") && item.visible) {
  641. // return {
  642. // data: "infos." + item.infopoint_code,
  643. // renderer: tools.lookDetails,
  644. // readOnly: true
  645. // }
  646. // }
  647. // if (item.infopoint_code == "SupplierContractID" && item.visible) {
  648. // return {
  649. // data: "infos." + item.infopoint_code,
  650. // renderer: tools.lookDetails,
  651. // readOnly: true
  652. // }
  653. // }
  654. if (item.infopoint_code == "InsuranceNum" && item.visible) {
  655. //选择保单
  656. return {
  657. data: "infos." + item.infopoint_code,
  658. renderer: tools.lookDetails,
  659. readOnly: true
  660. }
  661. }
  662. if ((item.infopoint_code == "InsuranceFile" || item.infopoint_code == "Archive") && item.visible) {
  663. return {
  664. data: "infos." + item.infopoint_code,
  665. renderer: tools.lookDetails,
  666. readOnly: true
  667. }
  668. }
  669. if (
  670. (
  671. item.infopoint_code == "InstallPic" ||
  672. item.infopoint_code == "InstallDrawing" ||
  673. item.infopoint_code == "Nameplate" ||
  674. item.infopoint_code == "Pic" ||
  675. item.infopoint_code == "Drawing"
  676. ) && item.visible
  677. ) {
  678. return {
  679. data: "infos." + item.infopoint_code,
  680. renderer: tools.lookDetails,
  681. readOnly: true
  682. }
  683. }
  684. if (
  685. (
  686. item.infopoint_code == "Maintainer" ||
  687. item.infopoint_code == "Supplier" ||
  688. item.infopoint_code == "Insurer" ||
  689. item.infopoint_code == "InsurerContactor"
  690. )
  691. && item.visible
  692. ) {
  693. return {
  694. data: "infos." + item.infopoint_code,
  695. }
  696. }
  697. if (item.collection_cmpt_code == "Enum" && item.visible) {
  698. return {
  699. data: "infos." + item.infopoint_code,
  700. renderer: this.customDropdownRenderer,
  701. editor: "chosen",
  702. chosenOptions: {
  703. // multiple: true,//多选
  704. data: item.dataSource || ""
  705. }
  706. };
  707. } else if (item.collection_cmpt_code == "Num" && item.visible) {
  708. return {
  709. data: "infos." + item.infopoint_code,
  710. type: "numeric",
  711. numericFormat: {
  712. pattern: "0,0.00"
  713. // culture: 'de-DE' // use this for EUR (German),
  714. // more cultures available on http://numbrojs.com/languages.html
  715. }
  716. };
  717. } else if (item.collection_cmpt_code == "Time" && item.visible) {
  718. return {
  719. data: "infos." + item.infopoint_code,
  720. type: "date",
  721. dateFormat: "YYYY-MM-DD",
  722. correctFormat: true
  723. };
  724. } else if (item.collection_cmpt_code == "text" && item.visible) {
  725. return {
  726. data: "infos." + item.infopoint_code
  727. };
  728. } else if (
  729. (item.info_point_code == "设备ID" ||
  730. item.info_point_code == "设备名称") && item.visible
  731. ) {
  732. return {
  733. data: "infos." + item.infopoint_code,
  734. readOnly: true
  735. };
  736. } else if (item.collection_cmpt_code == "checkBox" && item.visible) {
  737. return {
  738. data: "infos." + item.infopoint_code,
  739. renderer: this.customDropdownRenderer,
  740. editor: "chosen",
  741. chosenOptions: {
  742. multiple: true,//多选
  743. data: item.dataSource || ""
  744. }
  745. };
  746. } else if (item.collection_cmpt_code == "Own" && item.visible) {
  747. return {
  748. data: "infos." + item.infopoint_code,
  749. renderer: text.idType,
  750. }
  751. } else {
  752. return undefined
  753. }
  754. },
  755. //初始化插件
  756. initHot() {
  757. var container = document.getElementById("handsontable");
  758. let winHeight = document.documentElement.clientHeight;
  759. this.hot = new Handsontable(container, {
  760. data: this.main,
  761. fixedColumnsLeft: 5,
  762. colHeaders: this.delHeader(this.headers), //表头文案
  763. columns: this.getType(this.headers), //数据显示格式
  764. filters: true,
  765. maxRows: this.main.length,
  766. height: winHeight - 100 - 50 - 290,
  767. columnSorting: true, //添加排序
  768. sortIndicator: true, //添加排序
  769. renderAllRows: true,
  770. // colWidths: 200,
  771. autoColumnSize: true,
  772. language: "zh-CN",
  773. manualColumnResize: true,
  774. manualColumnMove: true,
  775. dropdownMenu: [
  776. "filter_by_condition",
  777. "filter_by_value",
  778. "filter_action_bar"
  779. ],
  780. contextMenu: {
  781. items: {
  782. remove_row: {
  783. name: "删除选中设备"
  784. }
  785. }
  786. },
  787. // 事件
  788. afterChange: this.tdChange, //修改后
  789. afterFilter: this.trimmedRows, //排序前
  790. afterRemoveRow: this.romoveFm, //右键删除
  791. afterOnCellMouseDown: this.eventClick //鼠标点击
  792. });
  793. let pro = document.getElementById("hot-display-license-info");
  794. if (!!pro) {
  795. pro.parentNode.removeChild(pro);
  796. }
  797. this.isLoading = false;
  798. },
  799. //表格中的点击
  800. eventClick(el, rowArr) {
  801. //点击的是表头
  802. if (rowArr.row < 0) {
  803. return;
  804. }
  805. //被筛选过后的数组
  806. let trimmedArr = this.trimmedRows();
  807. //是否启用了排序
  808. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  809. if (trimmedArr.length && isSort) {
  810. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  811. .__arrayMap;
  812. let infos = this.main[trimmedArr[sortArr[rowArr.row]]];
  813. this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col });
  814. } else if (isSort) {
  815. //排序后的数组
  816. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  817. let infos = this.main[sortArr[rowArr.row]];
  818. this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col });
  819. } else if (trimmedArr.length) {
  820. let infos = this.main[trimmedArr[rowArr.row]];
  821. this.getInfors(infos, { row: trimmedArr[rowArr.row], col: rowArr.col });
  822. } else {
  823. let infos = this.main[rowArr.row];
  824. this.getInfors(infos, rowArr);
  825. }
  826. },
  827. tdChange(changeData, source) {
  828. if (!this.onlyRead) {
  829. if (changeData) {
  830. let trimmedArr = this.trimmedRows();
  831. let param = handsonUtils.getParam(changeData, source, this.hot, trimmedArr);
  832. let data = [];
  833. for (let i = 0; i < param.length; i++) {
  834. data.push(param[i]);
  835. }
  836. //如果data中包含/且data长度为1,将其转换成.
  837. if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
  838. changeData[0][1] = changeData[0][1].split("/").join(".")
  839. }
  840. //存在data进行修改请求
  841. if (data && data.length) {
  842. this.updateBusiness(data, changeData);
  843. }
  844. }
  845. }
  846. },
  847. //删除资产
  848. romoveFm() {
  849. let params = tools.differenceArr(this.main, this.copyMain)
  850. let _this = this
  851. if (params.length < 1) {
  852. return
  853. }
  854. let param = {
  855. secret: this.mess.secret,
  856. ProjId: this.mess.ProjId,
  857. data: {
  858. "criterias": []
  859. }
  860. }
  861. params.map(item => {
  862. param.data.criterias.push({ id: item.id })
  863. })
  864. this.$confirm("此操作将删除设备,是否继续?", "提示", {
  865. confirmButtonText: '确定',
  866. cancelButtonText: '取消',
  867. type: 'warning'
  868. }).then(() => {
  869. this.removeSys(param)
  870. }).catch(() => {
  871. this.reset()
  872. this.$message("取消删除")
  873. })
  874. // delProperty(param, res => {
  875. // _this.$message.success("删除成功")
  876. // _this.getMain()
  877. // })
  878. },
  879. async removeSys(param) {
  880. await delBatchList(param, res => {
  881. this.$message.success("删除成功")
  882. this.getMain()
  883. })
  884. },
  885. // 修改
  886. updateBusiness(data, change) {
  887. // data.map(item => {
  888. // if (!!item.flowBuild) {
  889. // item.building_id = item.flowBuild.split("-")[0]
  890. // item.floor_id = item.flowBuild.split("-")[1] || null
  891. // //不存在floor字段去除floor
  892. // if (!item.floor_id) {
  893. // delete item.floor_id
  894. // }
  895. // delete item.flowBuild
  896. // }
  897. // })
  898. let param = {
  899. ProjId: this.mess.ProjId,
  900. secret: this.mess.secret,
  901. data: {
  902. criterias: []
  903. }
  904. };
  905. //生成对应修改数据
  906. data.map((item, index) => {
  907. let arr = change[index][1].split(".");
  908. let info = {};
  909. info[arr[1]] = [{ value: item[arr[0]][arr[1]] != "" ? item[arr[0]][arr[1]] : null }];
  910. param.data.criterias.push({
  911. id: item.id,
  912. infos: info
  913. });
  914. });
  915. //对五大厂商进行特殊处理
  916. param.data.criterias.map(item => {
  917. if (!!item.infos.DPSupplierID) {
  918. item.infos.DPSupplierID[0].value = item.infos.DPSupplierID[0].value.split("-")[0]
  919. }
  920. if (!!item.infos.DPManufacturerID) {
  921. item.infos.DPManufacturerID[0].value = item.infos.DPManufacturerID[0].value.split("-")[0]
  922. }
  923. if (!!item.infos.DPInsurerID) {
  924. item.infos.DPInsurerID[0].value = item.infos.DPInsurerID[0].value.split("-")[0]
  925. }
  926. if (!!item.infos.DPMaintainerID) {
  927. item.infos.DPMaintainerID[0].value = item.infos.DPMaintainerID[0].value.split("-")[0]
  928. }
  929. if (!!item.infos.DPSpecificationID) {
  930. item.infos.DPSpecificationID[0].value = item.infos.DPSpecificationID[0].value.split("-")[0]
  931. }
  932. return item
  933. })
  934. updateBusiness(param).then(res => {
  935. });
  936. },
  937. //修改设备类型
  938. changeCader() {
  939. this.EquipmentList.map(item => {
  940. if (!!item.content && item.content.length) {
  941. item.content.map(child => {
  942. if (child.code == this.mess.deviceId) {
  943. this.deviceType.assetType = item.code
  944. this.deviceType.assetName = item.name
  945. }
  946. })
  947. }
  948. })
  949. },
  950. //获取到了正确的信息
  951. getInfors(infos, row) {
  952. //其他的开始判断
  953. let val = this.hot.colToProp(row.col);
  954. this.row = row.row
  955. this.messKey = val
  956. this.systemId = infos.id
  957. if (val == "caozuo") {
  958. this.iframeSrc =
  959. process.env.BASE_URL +
  960. ":8889/#/details?perjectId=" +
  961. this.projectId +
  962. "&secret=" +
  963. this.secret +
  964. "&FmId=" +
  965. infos.id +
  966. "&type=1&code=" +
  967. infos.category.substring(2, 6);
  968. this.dialog.details = true
  969. }
  970. //图片弹窗
  971. if (
  972. val == "infos.InstallPic" ||
  973. val == "infos.InstallDrawing" ||
  974. val == "infos.Nameplate" ||
  975. val == "infos.Drawing"
  976. ) {
  977. if (this.onlyRead) {
  978. this.dialog.lookPic = true
  979. this.picsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
  980. } else {
  981. this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
  982. this.dialog.uploadImgs = true
  983. }
  984. }
  985. if (val == "linkSystem") {
  986. this.dialog.systemType = true
  987. }
  988. if (val == "infos.Pic") {
  989. this.picsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
  990. if (this.onlyRead) {
  991. this.dialog.lookPic = true
  992. } else {
  993. this.dialog.pic = true
  994. }
  995. }
  996. if (val == "infos.InsuranceFile" || val == "infos.Archive" || val == "infos.CheckReport") {
  997. this.filesArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
  998. this.dialog.uploadFiles = true
  999. }
  1000. if (val == "linkName" && this.linkNameFalg) {
  1001. this.category = this.main[row.row]
  1002. this.dialog.changeRea = true
  1003. }
  1004. if (val == "infos.EquipQRCode") {
  1005. this.qrcodeUrl = this.main[row.row].infos.EquipQRCode
  1006. if (!!this.qrcodeUrl) {
  1007. this.dialog.qrcode = true;
  1008. } else {
  1009. this.$message("此设备没有设备二维码")
  1010. }
  1011. }
  1012. if (this.onlyRead) {
  1013. return
  1014. }
  1015. if (val == "infos.DPManufacturerID") {
  1016. this.dialog.firm = true;
  1017. }
  1018. if (val == "infos.SupplierContractID") {
  1019. let falg = null
  1020. if (!!this.main[row.row].infos) {
  1021. if (!!this.main[row.row].infos.DPSupplierID) {
  1022. falg = this.main[row.row].infos.DPSupplierID.split("-")[0]
  1023. }
  1024. }
  1025. if (!!falg) {
  1026. this.id = falg
  1027. this.dialog.supply = true;
  1028. } else {
  1029. this.$message("请先选择供应商")
  1030. }
  1031. }
  1032. if (val == "infos.InsuranceNum") {
  1033. //选择保单
  1034. let falg = null
  1035. if (!!this.main[row.row].infos) {
  1036. if (!!this.main[row.row].infos.DPInsurerID) {
  1037. falg = this.main[row.row].infos.DPInsurerID.split("-")[0]
  1038. }
  1039. }
  1040. if (!!falg) {
  1041. this.id = falg
  1042. this.dialog.guarantee = true;
  1043. } else {
  1044. this.$message("请先选择保险商")
  1045. }
  1046. }
  1047. if (
  1048. val == "infos.DPSupplierID"
  1049. ) {
  1050. if (!!infos.linkId) {
  1051. this.dialog.supplier = true;
  1052. } else {
  1053. this.$message("该设备无关联资产")
  1054. }
  1055. }
  1056. if (val == "infos.DPMaintainerID") {
  1057. if (!!infos.linkId) {
  1058. this.dialog.maintainer = true;
  1059. } else {
  1060. this.$message("该设备无关联资产")
  1061. }
  1062. }
  1063. if (
  1064. val == "infos.DPInsurerID") {
  1065. if (!!infos.linkId) {
  1066. this.dialog.insurer = true;
  1067. } else {
  1068. this.$message("该设备无关联资产")
  1069. }
  1070. }
  1071. },
  1072. //获取被筛选掉的行号
  1073. trimmedRows() {
  1074. // var plugin = hot.getPlugin('trimRows').trimmedRows;//获取被筛选掉的行号
  1075. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  1076. let dataLength = this.main.length;
  1077. let dataArr = new Array();
  1078. for (let i = 0; i < dataLength; i++) {
  1079. dataArr.push(i);
  1080. }
  1081. if (plugin.length <= 0) {
  1082. dataArr = undefined;
  1083. } else {
  1084. dataArr = this.array_diff(dataArr, plugin);
  1085. }
  1086. return dataArr || [];
  1087. // var DataArray = new Array();
  1088. // for (var i = 0; i < plugin.length; i++) {
  1089. // // 通过行号获取数据
  1090. // DataArray.push(this.hot.getSourceDataAtRow(plugin[i]));
  1091. // }
  1092. },
  1093. //去除数组中相同的元素
  1094. array_diff(a, b) {
  1095. for (var i = 0; i < b.length; i++) {
  1096. for (var j = 0; j < a.length; j++) {
  1097. if (a[j] == b[i]) {
  1098. a.splice(j, 1);
  1099. j = j - 1;
  1100. }
  1101. }
  1102. }
  1103. return a;
  1104. },
  1105. //如果选择供应商之后
  1106. supplierChange(data) {
  1107. for (let key in data) {
  1108. if (key == "venderId") {
  1109. data[key] = data[key] + "-" + data.name
  1110. this.utilToKey(key, "venderId", data, "DPSupplierID")
  1111. }
  1112. }
  1113. // tools.setItem(this.deviceType.code, this.main)
  1114. },
  1115. supplyChange(data) {
  1116. let changeData = { id: data }
  1117. this.utilToKey("id", "id", changeData, "SupplierContractID")
  1118. // tools.setItem(this.deviceType.code, this.main)
  1119. },
  1120. //保险合同
  1121. guaranteeChange(data) {
  1122. for (let key in data) {
  1123. this.utilToKey(key, "insuranceNo", data, "InsuranceNum")
  1124. if (key == "contractFile") {
  1125. if (!!data[key]) {
  1126. data[key] = [data[key]]
  1127. }
  1128. }
  1129. this.utilToKey(key, "contractFile", data, "InsuranceFile")
  1130. }
  1131. // tools.setItem(this.deviceType.code, this.main)
  1132. },
  1133. //选择型号修改
  1134. firmChange(data) {
  1135. for (let key in data) {
  1136. // this.utilToKey(key, "name", data, "Supplier")
  1137. // this.utilToKey(key, "email", data, "SupplierEmail")
  1138. // this.utilToKey(key, "website", data, "SupplierWeb")
  1139. // this.utilToKey(key, "phone", data, "SupplierPhone")
  1140. // this.utilToKey(key, "fox", data, "SupplierFax")
  1141. // this.utilToKey(key, "man", data, "SupplierContactor")
  1142. if (key == "venderId") {
  1143. data[key] = data[key] + "-" + data.name + "/" + data.brand
  1144. this.utilToKey(key, "venderId", data, "DPManufacturerID")
  1145. }
  1146. this.utilToKey(key, "specificationId", data, "DPSpecificationID")
  1147. }
  1148. },
  1149. //保险商变更
  1150. changeInsurer(data) {
  1151. for (let key in data) {
  1152. // this.utilToKey(key, "name", data, "Insurer")
  1153. // this.utilToKey(key, "email", data, "InsurerEmail")
  1154. // this.utilToKey(key, "website", data, "InsurerWeb")
  1155. // this.utilToKey(key, "phone", data, "InsurerFax")
  1156. // this.utilToKey(key, "man", data, "InsurerContactor")
  1157. if (key == "venderId") {
  1158. data[key] = data[key] + "-" + data.name
  1159. this.utilToKey(key, "venderId", data, "DPInsurerID")
  1160. }
  1161. }
  1162. // tools.setItem(this.deviceType.code, this.main)
  1163. },
  1164. //维修商变更
  1165. changeMaintainer(data) {
  1166. for (let key in data) {
  1167. // this.utilToKey(key, "name", data, "Maintainer")
  1168. // this.utilToKey(key, "email", data, "MaintainerEmail")
  1169. // this.utilToKey(key, "website", data, "MaintainerWeb")
  1170. // this.utilToKey(key, "phone", data, "MaintainerPhone")
  1171. // this.utilToKey(key, "fox", data, "MaintainerFax")
  1172. // this.utilToKey(key, "man", data, "MaintainerContactor")
  1173. if (key == "venderId") {
  1174. data[key] = data[key] + "-" + data.name
  1175. this.utilToKey(key, "venderId", data, "DPMaintainerID")
  1176. }
  1177. }
  1178. // tools.setItem(this.deviceType.code, this.main)
  1179. },
  1180. //上传文件弹窗触发事件
  1181. fileChange(keys) {
  1182. this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
  1183. // tools.setItem(this.deviceType.code, this.main)
  1184. },
  1185. //上传图片弹窗触发事件
  1186. imgChange(keys) {
  1187. this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
  1188. // tools.setItem(this.deviceType.code, this.main)
  1189. },
  1190. //设备图片弹窗改变事件
  1191. changePics(keys) {
  1192. this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
  1193. // tools.setItem(this.deviceType.code, this.main)
  1194. },
  1195. utilToKey(key, name, data, messName) {
  1196. if (key == name) {
  1197. this.setDataToMain(data[key], messName, this.row)
  1198. }
  1199. },
  1200. //判断是否有值,有值赋值
  1201. setDataToMain(data, key, row) {
  1202. if (!!data && data != '--') {
  1203. if (!!this.main[row].infos) {
  1204. //falg确定每个的是否有值
  1205. this.main[row].infos[key] = data
  1206. this.updateBusiness([this.main[row]], [[0, "infos." + key, null, data]])
  1207. } else {
  1208. this.main[row].infos = {}
  1209. this.main[row].infos[key] = data
  1210. }
  1211. } else {
  1212. this.main[row].infos[key] = ''
  1213. }
  1214. }
  1215. }
  1216. };
  1217. </script>
  1218. <style lang="less">
  1219. .hanson-bar {
  1220. height: 40px;
  1221. padding: 5px;
  1222. font-size: 14px;
  1223. overflow: hidden;
  1224. margin-top: 10px;
  1225. line-height: 40px;
  1226. .iconfont {
  1227. font-size: 12px;
  1228. }
  1229. .el-button {
  1230. // margin-right: 10px;
  1231. }
  1232. }
  1233. </style>