device.vue 40 KB

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