assets.vue 38 KB

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