assets.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. <template>
  2. <div style="height: calc(100% - 44.5px);padding: 0px 10px 10px;box-sizing: border-box;">
  3. <div class="hanson-bar">
  4. <div style="float:right;overflow:hidden;">
  5. <!-- <span style="width:20px;float:left;display:block;height:20px;cursor: pointer;" @click="changeAssetsFalg">
  6. <i v-if="!onlyRead" class="el-icon-fa el-icon-fa-eye"></i>
  7. </span> -->
  8. <span>当前筛选条件下共{{page.total || '--'}}设备</span>
  9. </div>
  10. <el-select v-model="onlyRead" @change="getHeaderData(mess)" style="width:100px;margin-right:20px;vertical-align:bottom;">
  11. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
  12. </el-select>
  13. <el-select v-model="showType" @change="initTable" style="width:130px;margin-right:10px;vertical-align:bottom;">
  14. <el-option v-for="item in showTypes" :key="item.value" :label="item.label" :value="item.value"></el-option>
  15. </el-select>
  16. <el-button size="small" style="width: 80px;" @click="addDevice" icon="iconfont icon-tianjia">添加资产</el-button>
  17. <el-button size="small" style="width: 80px;" @click="reset" icon="iconfont icon-shuaxin">刷新</el-button>
  18. <el-button v-show="!onlyRead" size="small" style="width: 80px;" @click="undo" icon="iconfont icon-undo">撤销</el-button>
  19. </div>
  20. <qrcode :qrcodeUrl="qrcodeUrl" :dialog="myDialog" :addBody="true" ref="qrcode"></qrcode>
  21. <firm ref="firm" :mess="mess" @changeFirm="firmChange" :dialog="myDialog"></firm>
  22. <supply-dialog @change="supplyChange" ref="supply" :id="id" :dialog="myDialog"></supply-dialog>
  23. <supplier-dialog ref="supplier" @changeSupplier="supplierChange" :dialog="myDialog"></supplier-dialog>
  24. <guarantee-dialog @change="guaranteeChange" :id="id" ref="guarantee" :dialog="myDialog"></guarantee-dialog>
  25. <upload-files-dialog :read="onlyRead ? true : false" ref="upload" @changeFile="fileChange" :keysArr="filesArr" :dialog="myDialog" ></upload-files-dialog>
  26. <upload-img-dialog :read="onlyRead ? true : false" @changeFile="imgChange" :keysArr="imgsArr" :dialog="myDialog" ></upload-img-dialog>
  27. <maintainer-dialog @changeMaintainer="changeMaintainer" ref="maintainer" :dialog="myDialog"></maintainer-dialog>
  28. <insurer-dialog @changeInsurer="changeInsurer" ref="insurer" :dialog="myDialog"></insurer-dialog>
  29. <pic-dialog :read="onlyRead ? true : false" :dialog="myDialog" :keysArr="picsArr" @change="changePics" ></pic-dialog>
  30. <div class="center middle_sty" style="height: 91%" v-show="!mess.deviceId && (!tableData || !tableData.length)">
  31. <p>
  32. <i class="icon-wushuju iconfont"></i>
  33. 请选择设备族
  34. </p>
  35. </div>
  36. <div class="center middle_sty" style="height: 91%" v-show="mess.deviceId && (!tableData || !tableData.length)">
  37. <p>
  38. <i class="icon-wushuju iconfont"></i>
  39. 暂无数据
  40. </p>
  41. </div>
  42. <div v-show="mess.deviceId && tableData && tableData.length" v-loading="loading" id="handsontable" ref="handsontable"></div>
  43. <div v-show="tableData && tableData.length" class='right'>
  44. <my-pagination @change="getTableData" :page="page"></my-pagination>
  45. </div>
  46. <!-- <dialog-assets :assetType="[this.mess.deviceId]" @close="closeDialog" ref="assets" v-if="myDialog.addDevice" :dialog="myDialog" ></dialog-assets> -->
  47. <details-dialog :iframeSrc="iframeSrc" v-if="myDialog.details" :dialog="myDialog"></details-dialog>
  48. <look-pic :dialog="myDialog" :keysArr="picsArr"></look-pic>
  49. <!-- 新增资产 -->
  50. <el-dialog class="add-assets" :title="showAddByDie?'未关联资产的设备批量创建资产':'确定新增资产类型'" @close="showAddByDie = false" :visible.sync="myDialog.addDevice" width="670px">
  51. <el-row>
  52. <my-cascader v-show="!showAddByDie" ref="cascader" @change="changeCader"></my-cascader>
  53. <die-cascader v-show="showAddByDie" ref="dieCascader" :Family="addData.Family" @change="changeDevice"></die-cascader>
  54. <floor-cascader v-show="showAddByDie" @change="changeFloor"></floor-cascader>
  55. <div class="die-text" v-show="showAddByDie">当前筛选条件下有<span class="die-num">{{dieNum}}</span>个设备可批量创建资产。</div>
  56. <el-link v-show="showAddByDie && dieNum" type="primary" :underline="false" @click="toDetaiPage" style="margin-left:10px;">查看详情</el-link>
  57. </el-row>
  58. <span slot="footer" class="dialog-footer">
  59. <el-button v-show="!showAddByDie" type="primary" @click="toAddbyDie">批量创建</el-button>
  60. <el-button v-show="!showAddByDie" type="primary" @click="toAddDevice">手动添加</el-button>
  61. <el-button v-show="showAddByDie" type="primary" @click="showAddByDie = false">返回</el-button>
  62. <el-button v-show="showAddByDie" type="primary" :disabled="dieNum == 0" @click="createByDie">批量创建</el-button>
  63. </span>
  64. </el-dialog>
  65. </div>
  66. </template>
  67. <script>
  68. import { getDataDictionary, queryProperty, propertyLinkEq, updateProperty, deleteProperty, countPartsDie, createPropertys, BeatchQueryParam } from "@/api/scan/request";
  69. import tools from "@/utils/scan/tools"
  70. import handsonUtils from "@/utils/scan/hasontableUtils"
  71. import showTools from "@/utils/handsontable/notShow"
  72. import text from "@/utils/handsontable/mainText"
  73. import buildFloor from '@/utils/handsontable/buildFloorData'
  74. import qrcode from "@/components/business_space/lib/qrcode"
  75. import firm from "@/components/business_space/dialogs/list/firm"
  76. import supplyDialog from "@/components/business_space/dialogs/list/supplyDialog"
  77. import supplierDialog from "@/components/business_space/dialogs/list/supplierDialog"
  78. import maintainerDialog from "@/components/business_space/dialogs/list/maintainerDialog"
  79. import insurerDialog from "@/components/business_space/dialogs/list/insurerDialog"
  80. import guaranteeDialog from "@/components/business_space/dialogs/list/guaranteeDialog"
  81. import uploadFilesDialog from "@/components/business_space/dialogs/list/filesDialog"
  82. import uploadImgDialog from "@/components/business_space/dialogs/list/uploadImgDialog"
  83. import detailsDialog from "@/components/business_space/lib/detailsDia"
  84. import picDialog from "@/components/business_space/dialogs/list/picDialog"
  85. import myPagination from "@/components/common/myPagination"
  86. import dialogAssets from "@/components/ledger/addDialog/dialogAssets"
  87. import myCascader from "@/components/ledger/lib/assets"
  88. import floorCascader from "@/components/ledger/lib/floorCascader"
  89. import dieCascader from "@/components/ledger/lib/partsDieList"
  90. import { mapGetters, mapActions } from "vuex"
  91. //图片查看
  92. import lookPic from "@/components/ledger/lib/lookImages"
  93. import Handsontable from "handsontable-pro"
  94. import 'handsontable-pro/dist/handsontable.full.css'
  95. import zhCN from 'handsontable-pro/languages/zh-CN'
  96. //下拉插件
  97. // import "@/assets/js/chosen.jquery.min";
  98. // import "@/assets/js/handsontable-chosen-editor";
  99. export default {
  100. components: {
  101. qrcode, //二维码页面
  102. firm, //
  103. supplyDialog,
  104. supplierDialog,
  105. guaranteeDialog,
  106. uploadFilesDialog,
  107. maintainerDialog,
  108. insurerDialog,
  109. uploadImgDialog,
  110. picDialog,
  111. myPagination,
  112. // dialogAssets,
  113. myCascader,
  114. floorCascader,
  115. dieCascader,
  116. detailsDialog,
  117. lookPic
  118. },
  119. created() {
  120. buildFloor.getData(this.buildFloorData)
  121. },
  122. computed: {
  123. ...mapGetters("layout", [ "projectId", "secret", "userId" ]),
  124. showTypes() {
  125. return this.onlyRead ?
  126. [{ value: "Visible", label: '只看采集信息' }, { value: "all", label: '全部' }] :
  127. [{ value: "partInfo", label: '隐藏信息点' }, { value: "Visible", label: '只看采集信息' }, { value: "all", label: '全部' }]
  128. }
  129. },
  130. data() {
  131. return {
  132. options: [{
  133. value: true,
  134. label: '只读模式'
  135. }, {
  136. value: false,
  137. label: '编辑模式'
  138. }],
  139. buildFloorData: [], //楼层数据
  140. tableData: [],
  141. mess: {},
  142. tableHeader: null,
  143. page: {
  144. size: 50,
  145. sizes: [10, 30, 50, 100, 150, 200],
  146. total: 0,
  147. currentPage: 1
  148. },
  149. myDialog: {
  150. qrcode: false, //二维码弹窗
  151. firm: false, //厂商弹窗
  152. supply: false, //选择供应合同
  153. supplier: false, //供应商选择
  154. guarantee: false, //选择保单
  155. maintainer: false, //选择维修商
  156. insurer: false, //选择保险公司
  157. uploadFiles: false,//上传文件
  158. uploadImgs: false,//上传单个图片
  159. pic: false, //多个图片
  160. addDevice: false,//添加资产
  161. systemType: false,//关联系统
  162. details: false,//详情页
  163. changeRea: false,//关联资产
  164. lookPic: false,//图片查看
  165. },
  166. row: null, //被修改的row
  167. filesArr: [], //保存临时的文件key
  168. messKey: null,
  169. imgsArr: [], //临时保存的图片key数组
  170. picsArr: [], //临时资产图片keys数组
  171. copyMain: null,
  172. graphyId: null,
  173. assetGroupList: [],
  174. iframeSrc: "",
  175. id: 0,
  176. onlyRead: true,
  177. showType: 'all',
  178. linkNameFalg: false,
  179. qrcodeUrl: "", //二维码图片地址
  180. loading: false,
  181. deviceType: {}, //族3位编码及名称
  182. floorData: [],
  183. curDevice: '',//当前点击的资产id
  184. showAddByDie: false,//是否显示通过设备添加资产页面
  185. addData: {}, //添加资产选择的资产类型
  186. numParams: { // 查询设备部件数量条件
  187. category:'',
  188. buildId:'',
  189. floorId:'',
  190. Family:''
  191. },
  192. dieNum: 0 // 查询设备部件数量
  193. };
  194. },
  195. methods: {
  196. //获取表头
  197. getHeaderData(code) {
  198. this.page.currentPage = 1
  199. this.mess = code
  200. if (this.mess.deviceId) {
  201. let params = {
  202. data: {
  203. Orders: "sort asc",
  204. PageNumber: 1,
  205. PageSize: 500
  206. },
  207. type: this.mess.deviceId
  208. };
  209. getDataDictionary(params, res => {
  210. this.tableHeader = res.Content;
  211. this.getTableData()
  212. });
  213. }
  214. },
  215. //获取主体数据
  216. getTableData() {
  217. this.loading = true
  218. //type存在发送请求
  219. if (!!this.mess.deviceId) {
  220. let param = {
  221. PageSize: this.page.size,
  222. Orders: "createTime desc, EquipID desc",
  223. PageNumber: this.page.currentPage,
  224. Filters: `Family='${this.mess.deviceId}'`
  225. }
  226. if (this.mess.buildId == "noKnow") {
  227. param.Filters += `;buildingId isNull`
  228. } else if (this.mess.buildId && this.mess.buildId != "all") {
  229. param.Filters += `;buildingId='${this.mess.buildId}'`
  230. }
  231. if (this.mess.floorId == "noKnow") {
  232. param.Filters += `;floorId isNull`
  233. } else if (this.mess.floorId && this.mess.floorId != "all") {
  234. param.Filters += `;floorId='${this.mess.floorId}'`
  235. }
  236. propertyLinkEq(param, res => {
  237. this.loading = false
  238. this.tableData = res.Content.map((item) => {
  239. if (item.hasOwnProperty("BuildingId") && item.hasOwnProperty("FloorId")) {
  240. item.flowBuild = item.BuildingId + "-" + item.FloorId
  241. } else if (item.hasOwnProperty("BuildingId") && !item.hasOwnProperty("FloorId")) {
  242. item.flowBuild = item.BuildingId
  243. }
  244. return item
  245. })
  246. this.copyMain = tools.deepCopy(this.tableData)
  247. this.page.total = res.Total
  248. if (this.hot) {
  249. this.hot.destroy()
  250. this.hot = null
  251. }
  252. if (this.tableData && this.tableData.length) {
  253. // if (this.onlyRead) {
  254. // this.getBatch(this.tableData)
  255. // }
  256. this.initTable()
  257. }
  258. })
  259. }
  260. },
  261. //获取动态参数
  262. getBatch(data) {
  263. let param = {
  264. secret: this.secret,
  265. ProjId: this.projectId,
  266. data: {
  267. criterias: []
  268. }
  269. };
  270. this.tableHeader.map(head => {
  271. if (
  272. head.InputMode == "L" ||
  273. head.InputMode == "L1" ||
  274. head.InputMode == "L2" ||
  275. head.InputMode == "M"
  276. ) {
  277. data.map(item => {
  278. let cur = tools.dataForKey(item, head.Path);
  279. if (cur) {
  280. param.data.criterias.push({
  281. id: item.EquipID,
  282. code: head.InfoPointCode
  283. });
  284. }
  285. });
  286. }
  287. });
  288. if (param.data.criterias.length) {
  289. BeatchQueryParam(param, res => {
  290. this.tableData = data.map(item => {
  291. res.Content.map(child => {
  292. if (item.EquipID == child.id) {
  293. if (child.data || child.data == 0) {
  294. this.tableHeader.map(head => {
  295. if (head.InfoPointCode == child.code) {
  296. tools.setDataForKey(item, head.Path, child.data);
  297. }
  298. });
  299. } else {
  300. this.tableHeader.map(head => {
  301. if (head.InfoPointCode == child.code) {
  302. tools.setDataForKey(
  303. item,
  304. head.Path,
  305. child.error ? "表号功能号格式错误" : "表号功能号不存在"
  306. );
  307. }
  308. });
  309. }
  310. }
  311. });
  312. return item;
  313. });
  314. this.hot.loadData(this.tableData);
  315. });
  316. }
  317. },
  318. //撤回
  319. undo() {
  320. this.hot.undo();
  321. },
  322. //刷新-switch改变
  323. reset() {
  324. this.getTableData();
  325. },
  326. //添加资产
  327. addDevice() {
  328. this.myDialog.addDevice = true
  329. if (this.mess.deviceId) {
  330. this.$nextTick(() => {
  331. this.$refs.cascader.setValue([this.mess.deviceId])
  332. this.addData.Family = this.mess.deviceId
  333. this.numParams.Family = this.mess.deviceId
  334. })
  335. }
  336. },
  337. //手动创建
  338. toAddDevice() {
  339. if (this.addData.Family) {
  340. this.$router.push({
  341. path: "/ledger/propertyadd",
  342. query: this.addData
  343. });
  344. } else {
  345. this.$message("请选择设备族")
  346. }
  347. },
  348. //显示通过部件或设备创建资产页
  349. toAddbyDie() {
  350. if (this.addData.Family) {
  351. this.showAddByDie = true
  352. this.$nextTick(() => {
  353. this.$refs.dieCascader.getAllData()
  354. })
  355. } else {
  356. this.$message("请选择设备族")
  357. }
  358. },
  359. //格式化条件
  360. formatFilter() {
  361. let param = {
  362. Filters: `category='${this.numParams.category}';PropertyId isNull`
  363. }
  364. if (this.numParams.buildId == "noKnow") {
  365. param.Filters += `;buildingId isNull`
  366. } else if (this.numParams.buildId && this.numParams.buildId != "all") {
  367. param.Filters += `;buildingId='${this.numParams.buildId}'`
  368. }
  369. if (this.numParams.floorId == "noKnow") {
  370. param.Filters += `;floorId isNull`
  371. } else if (this.numParams.floorId && this.numParams.floorId != "all") {
  372. param.Filters += `;floorId='${this.numParams.floorId}'`
  373. }
  374. return param
  375. },
  376. //批量添加
  377. createByDie() {
  378. let param = this.formatFilter()
  379. createPropertys(param, res => {
  380. this.myDialog.addDevice = false
  381. this.$emit('getJson',{code: this.numParams.Family})
  382. this.$message.success("创建成功!")
  383. })
  384. },
  385. //获取未关联资产的设备或部件数量
  386. getNumDie() {
  387. let param = this.formatFilter()
  388. countPartsDie(param, res => {
  389. this.dieNum = res.Count
  390. })
  391. },
  392. //查看详情
  393. toDetaiPage() {
  394. this.$router.push({
  395. path: "/ledger/addPropertys",
  396. query: this.numParams
  397. })
  398. },
  399. //选择设备类型-添加资产
  400. changeCader(val) {
  401. this.addData.Family = val.code
  402. this.addData.name = val.facility
  403. this.numParams.Family = val.code
  404. },
  405. //选择设备或部件
  406. changeDevice(val) {
  407. if(val.code) {
  408. this.numParams.category = val.code
  409. } else {
  410. this.numParams.category = ''
  411. }
  412. this.getNumDie()
  413. },
  414. //选择建筑楼层
  415. changeFloor(value) {
  416. if (value[0]) {
  417. this.numParams.buildId = value[0]
  418. }
  419. if (value[1]) {
  420. this.numParams.floorId = value[1]
  421. } else {
  422. this.numParams.floorId = ''
  423. }
  424. this.getNumDie()
  425. },
  426. //下载
  427. download() {
  428. if (!this.onlyRead) {
  429. if (!!this.hot) {
  430. let fileName = this.mess.name + "-页数:" + this.page.currentPage + "-个数:" + this.tableData.length + "-总个数:" + this.page.total
  431. this.hot.getPlugin('exportFile').downloadFile("csv", { filename: fileName, columnHeaders: true, exportHiddenRows: true, exportHiddenColumns: true, rowHeaders: true })
  432. } else {
  433. this.$message("请确定存在表格")
  434. }
  435. } else {
  436. this.$message("下载需在编辑状态下")
  437. }
  438. },
  439. //格式化表头
  440. formatHeaderData(list) {
  441. let arr = tools.copyArr(list)
  442. let data = showTools.headerTextFilter(arr, 'property', this.onlyRead, this.showType, true)
  443. data.unshift("操作", "当前关联的设备")
  444. if (this.showType == "all") {
  445. data.splice(4, 0, "所属建筑楼层")
  446. }
  447. return data
  448. },
  449. //格式化表内容
  450. formatHeaderType(list) {
  451. let arr = tools.copyArr(list)
  452. let data = showTools.headerTypeFilter(arr, 'property', this.onlyRead, this.showType, true)
  453. data.unshift(
  454. {
  455. data: "caozuo",
  456. renderer: tools.lookDetails
  457. }, {
  458. data: "LinkEquipLocalName",
  459. renderer: tools.LinkEquipLocalName,
  460. readOnly: true
  461. }
  462. )
  463. if (this.showType == "all") {
  464. data.splice(4, 0, {
  465. data: "flowBuild",
  466. renderer: tools.customDropdownRenderer,
  467. editor: "chosen",
  468. chosenOptions: {
  469. data: this.buildFloorData
  470. },
  471. readOnly: this.onlyRead
  472. })
  473. }
  474. return data
  475. },
  476. //初始化插件
  477. initTable() {
  478. var container = document.getElementById("handsontable");
  479. let winHeight = document.documentElement.clientHeight;
  480. this.hot = new Handsontable(container, {
  481. data: this.tableData,
  482. fixedColumnsLeft: 4,
  483. colHeaders: this.formatHeaderData(this.tableHeader), //表头文案
  484. columns: this.formatHeaderType(this.tableHeader), //数据显示格式
  485. filters: true,
  486. maxRows: this.tableData.length,
  487. height: winHeight - 335,
  488. columnSorting: true, //添加排序
  489. sortIndicator: true, //添加排序
  490. renderAllRows: true,
  491. // colWidths: 200,
  492. autoColumnSize: true,
  493. language: "zh-CN",
  494. manualColumnResize: true,
  495. manualColumnMove: true,
  496. dropdownMenu: [
  497. "filter_by_condition",
  498. "filter_by_value",
  499. "filter_action_bar"
  500. ],
  501. contextMenu: {
  502. items: {
  503. remove_row: {
  504. name: "删除选中资产"
  505. }
  506. }
  507. },
  508. // 事件
  509. afterChange: this.handleUpdataTable, //修改后
  510. afterFilter: this.trimmedRows, //排序前
  511. afterRemoveRow: this.handleDeleteTableRow, //右键删除
  512. afterOnCellMouseDown: this.eventClick //鼠标点击
  513. });
  514. let pro = document.getElementById("hot-display-license-info");
  515. if (!!pro) {
  516. pro.parentNode.removeChild(pro);
  517. }
  518. this.isLoading = false;
  519. },
  520. //表格中的点击
  521. eventClick(el, rowArr) {
  522. //点击的是表头
  523. if (rowArr.row < 0) {
  524. return;
  525. }
  526. //被筛选过后的数组
  527. let trimmedArr = this.trimmedRows();
  528. //是否启用了排序
  529. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  530. if (trimmedArr.length && isSort) {
  531. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  532. .__arrayMap;
  533. let infos = this.tableData[trimmedArr[sortArr[rowArr.row]]];
  534. this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col }, el);
  535. } else if (isSort) {
  536. //排序后的数组
  537. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  538. let infos = this.tableData[sortArr[rowArr.row]];
  539. this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col }, el);
  540. } else if (trimmedArr.length) {
  541. let infos = this.tableData[trimmedArr[rowArr.row]];
  542. this.getInfors(infos, { row: trimmedArr[rowArr.row], col: rowArr.col }, el);
  543. } else {
  544. let infos = this.tableData[rowArr.row];
  545. this.getInfors(infos, rowArr, el);
  546. }
  547. },
  548. // 更新
  549. handleUpdataTable(changeData, source) {
  550. if (!this.onlyRead) {
  551. if (changeData) {
  552. let trimmedArr = this.trimmedRows();
  553. let param = handsonUtils.getParam(changeData, source, this.hot, trimmedArr);
  554. let data = [];
  555. for (let i = 0; i < param.length; i++) {
  556. data.push(param[i]);
  557. }
  558. //如果data中包含/且data长度为1,将其转换成.
  559. if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
  560. changeData[0][1] = changeData[0][1].split("/").join(".")
  561. }
  562. //存在data进行修改请求
  563. if (data && data.length) {
  564. this.updateProperty(data, changeData);
  565. }
  566. }
  567. }
  568. },
  569. //删除资产
  570. handleDeleteTableRow() {
  571. let params = tools.differenceArr(this.tableData, this.copyMain)
  572. let _this = this
  573. if (params.length < 1) {
  574. return
  575. }
  576. let param = []
  577. params.map(item => {
  578. param.push({ EquipID: item.EquipID })
  579. })
  580. this.$confirm("此操作将删除资产,是否继续?", "提示", {
  581. confirmButtonText: '确定',
  582. cancelButtonText: '取消',
  583. type: 'warning'
  584. }).then(() => {
  585. this.removeDevice(param)
  586. }).catch(() => {
  587. this.reset()
  588. this.$message("取消删除")
  589. })
  590. },
  591. // 删除资产
  592. async removeDevice(param) {
  593. await deleteProperty(param, res => {
  594. this.$message.success("删除成功")
  595. this.$emit('close','')
  596. this.getTableData()
  597. })
  598. },
  599. // 更新
  600. updateProperty(data, change) {
  601. let param = {
  602. Content: [],
  603. Projection: []
  604. }
  605. //生成要修改字段列表
  606. change.map(item => {
  607. if (item[1] && param.Projection.indexOf(item[1]) == -1) {
  608. if (item[1].split(".")[0] == "flowBuild") {
  609. param.Projection.push("BuildingId","FloorId")
  610. } else {
  611. param.Projection.push(item[1].split(".")[0])
  612. }
  613. }
  614. })
  615. //生成对应修改数据
  616. data.map((item, index) => {
  617. param.Projection.map(value => {
  618. if (value == "BuildingId") {
  619. let itemData = tools.dataForKey(item, "flowBuild")
  620. if (itemData == "") {
  621. tools.setDataForKey(item, "BuildingId", null)
  622. tools.setDataForKey(item, "FloorId", null)
  623. } else {
  624. let BuildingId = itemData.split("-")[0]
  625. let FloorId = itemData.split("-")[1]
  626. if (BuildingId && FloorId) {
  627. tools.setDataForKey(item, "BuildingId", BuildingId)
  628. tools.setDataForKey(item, "FloorId", FloorId)
  629. } else if (BuildingId && !FloorId) {
  630. tools.setDataForKey(item, "BuildingId", BuildingId)
  631. tools.setDataForKey(item, "FloorId", null)
  632. }
  633. }
  634. } else {
  635. let itemData = tools.dataForKey(item, value)
  636. tools.setDataForKey(item, value, itemData == "" ? null : itemData)
  637. }
  638. });
  639. param.Content.push(item)
  640. })
  641. param.Projection = []
  642. updateProperty(param, res => { })
  643. },
  644. //修改资产类型
  645. // changeCader() {
  646. // if (this.mess.deviceId) {
  647. // let param = {
  648. // data: {
  649. // Filters: `EquipCode='${this.mess.deviceId}'`,
  650. // PageNumber: 1,
  651. // PageSize: 50
  652. // }
  653. // }
  654. // getEquipBelongs(param, res => {
  655. // if (res.Content.length) {
  656. // this.deviceType.assetType = res.Content[0].Family
  657. // this.deviceType.assetName = res.Content[0].FamilyName
  658. // }
  659. // })
  660. // }
  661. // },
  662. //获取到了正确的信息
  663. getInfors(infos, row, el) {
  664. let val = this.hot.colToProp(row.col);
  665. this.row = row.row;
  666. this.messKey = val;
  667. switch (val) {
  668. //操作
  669. case 'caozuo':
  670. // window.open(`http://adm.sagacloud.cn:8058/spread?id=${infos.EquipID}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
  671. this.$message("开发中...")
  672. break;
  673. //资产二维码图片
  674. case 'EquipQRCode':
  675. this.qrcodeUrl = this.tableData[row.row].EquipQRCode;
  676. if (!!this.qrcodeUrl) {
  677. this.myDialog.qrcode = true;
  678. } else {
  679. this.$message("此资产没有资产二维码");
  680. }
  681. break;
  682. //关联系统
  683. case 'LinkSystem':
  684. if (!this.onlyRead) {
  685. this.curDevice = infos.EquipID;
  686. this.systemList = this.tableData[row.row].LinkSystem || [];
  687. this.myDialog.systemType = true;
  688. }
  689. break;
  690. //关联资产
  691. case 'LinkEquipLocalName':
  692. if (this.linkNameFalg) {
  693. this.myDialog.changeRea = true;
  694. }
  695. break;
  696. //品牌型号弹窗
  697. case 'DPManufacturerID':
  698. if (!this.onlyRead) {
  699. this.myDialog.firm = true;
  700. }
  701. break;
  702. //供应商信息弹窗
  703. case 'DPSupplierID':
  704. if (!this.onlyRead) {
  705. this.myDialog.supplier = true;
  706. }
  707. break;
  708. //维修商信息弹窗
  709. case 'DPMaintainerID':
  710. if (!this.onlyRead) {
  711. this.myDialog.maintainer = true;
  712. }
  713. break;
  714. //保险公司信息
  715. case 'DPInsurerID':
  716. if (!this.onlyRead) {
  717. this.myDialog.insurer = true;
  718. }
  719. break;
  720. //供应合同编号
  721. case 'LedgerParam.SupplyPurchase.SupplierContractID':
  722. if (!this.onlyRead) {
  723. let ContractIDflag = null;
  724. let DPSdata = this.tableData[row.row].DPSupplierID;
  725. if (DPSdata) {
  726. ContractIDflag = DPSdata.split("-")[0];
  727. }
  728. if (!!ContractIDflag) {
  729. this.id = ContractIDflag;
  730. this.myDialog.supply = true;
  731. } else {
  732. this.$message("请先选择供应商");
  733. }
  734. }
  735. break;
  736. //保险单号
  737. case 'LedgerParam.InsuranceDoc.InsuranceNum':
  738. if (!this.onlyRead) {
  739. let DPInsurerIDflag = null;
  740. let DPIdata = this.tableData[row.row].DPInsurerID;
  741. if (DPIdata) {
  742. DPInsurerIDflag = DPIdata.split("-")[0];
  743. }
  744. if (!!DPInsurerIDflag) {
  745. this.id = DPInsurerIDflag;
  746. this.myDialog.guarantee = true;
  747. } else {
  748. this.$message("请先选择保险商");
  749. }
  750. }
  751. break;
  752. //保险文件--资产文档--安装质检报告
  753. case 'LedgerParam.InsuranceDoc.InsuranceFile':
  754. case 'LedgerParam.PhotoDoc.Archive':
  755. case 'LedgerParam.Siteinstall.CheckReport':
  756. let IPSdata = tools.dataForKey(this.tableData[row.row], val);
  757. this.filesArr = IPSdata ? IPSdata : [];
  758. this.myDialog.uploadFiles = true;
  759. break;
  760. //安装照片--安装图纸--资产铭牌照片--资产图纸
  761. case 'LedgerParam.Siteinstall.InstallPic':
  762. case 'LedgerParam.Siteinstall.InstallDrawing':
  763. case 'LedgerParam.PhotoDoc.Nameplate':
  764. case 'LedgerParam.PhotoDoc.Drawing':
  765. let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
  766. this.imgsArr = SSPPdata ? SSPPdata : [];
  767. this.myDialog.uploadImgs = true;
  768. break;
  769. //资产照片
  770. case 'LedgerParam.PhotoDoc.Pic':
  771. let Pdata = tools.dataForKey(this.tableData[row.row], val);
  772. this.picsArr = Pdata ? Pdata : [];
  773. this.myDialog.pic = true;
  774. break;
  775. //包含的部件字段
  776. case 'Count':
  777. if (this.onlyRead) {
  778. this.$router.push({ path: '/ledger/parts', query: { deviceId: infos.EquipID } });
  779. } else {
  780. this.$router.push({ path: '/ledger/partsmanage', query: { deviceId: infos.EquipID, typeId: this.mess.deviceId } });
  781. }
  782. break;
  783. default:
  784. break;
  785. }
  786. },
  787. //获取被筛选掉的行号
  788. trimmedRows() {
  789. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  790. let dataLength = this.tableData.length;
  791. let dataArr = new Array();
  792. for (let i = 0; i < dataLength; i++) {
  793. dataArr.push(i);
  794. }
  795. if (plugin.length <= 0) {
  796. dataArr = undefined;
  797. } else {
  798. dataArr = this.array_diff(dataArr, plugin);
  799. }
  800. return dataArr || [];
  801. },
  802. //去除数组中相同的元素
  803. array_diff(a, b) {
  804. for (var i = 0; i < b.length; i++) {
  805. for (var j = 0; j < a.length; j++) {
  806. if (a[j] == b[i]) {
  807. a.splice(j, 1);
  808. j = j - 1;
  809. }
  810. }
  811. }
  812. return a;
  813. },
  814. //如果选择供应商之后
  815. supplierChange(data) {
  816. tools.setDataForKey(this.tableData[this.row], "DPSupplierID", data.venderId)
  817. tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.Supplier", data.name)
  818. this.handleUpdataTable([[this.row, "DPSupplierID", null, data.venderId]], "edit")
  819. this.handleUpdataTable([[this.row, "LedgerParam.SupplyPurchase.Supplier", null, data.name]], "edit")
  820. },
  821. //供应合同编号
  822. supplyChange(data) {
  823. tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.SupplierContractID", { id: data })
  824. },
  825. //保险单号-保险文件
  826. guaranteeChange(data) {
  827. for (let key in data) {
  828. this.utilToKey(key, "insuranceNo", data, "InsuranceNum")
  829. if (key == "contractFile") {
  830. if (!!data[key]) {
  831. data[key] = [data[key]]
  832. }
  833. }
  834. this.utilToKey(key, "contractFile", data, "InsuranceFile")
  835. }
  836. },
  837. //选择型号修改
  838. firmChange(data) {
  839. tools.setDataForKey(this.tableData[this.row], "DPManufacturerID", data.venderId)
  840. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Brand", data.brand)
  841. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Specification", data.name)
  842. this.handleUpdataTable([[this.row, "DPManufacturerID", null, data.venderId]], "edit")
  843. this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Brand", null, data.brand]], "edit")
  844. this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Specification", null, data.name]], "edit")
  845. },
  846. //保险商变更
  847. changeInsurer(data) {
  848. tools.setDataForKey(this.tableData[this.row], "DPInsurerID", data.venderId)
  849. tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.Insurer", data.name)
  850. this.handleUpdataTable([[this.row, "DPInsurerID", null, data.venderId]], "edit")
  851. this.handleUpdataTable([[this.row, "LedgerParam.InsuranceDoc.Insurer", null, data.name]], "edit")
  852. },
  853. //维修商变更
  854. changeMaintainer(data) {
  855. tools.setDataForKey(this.tableData[this.row], "DPMaintainerID", data.venderId)
  856. tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.Maintainer", data.name)
  857. this.handleUpdataTable([[this.row, "DPMaintainerID", null, data.venderId]], "edit")
  858. this.handleUpdataTable([[this.row, "LedgerParam.OperationMainte.Maintainer", null, data.name]], "edit")
  859. },
  860. //修改关联的资产
  861. changeProperty(val) {
  862. this.setDataToMain(val.PropertyId, 'PropertyId', this.row);
  863. this.setDataToMain(val.LinkEquipLocalName, 'LinkEquipLocalName', this.row);
  864. },
  865. //上传文件弹窗触发事件
  866. fileChange(keys) {
  867. this.setDataToMain(keys, this.messKey, this.row);
  868. },
  869. //上传图片弹窗触发事件
  870. imgChange(keys) {
  871. this.setDataToMain(keys, this.messKey, this.row);
  872. },
  873. //关联系统更改
  874. changeSystemType(data) {
  875. tools.setDataForKey(this.tableData[this.row], "LinkSystem", data)
  876. },
  877. //资产图片弹窗改变事件
  878. changePics(keys) {
  879. this.setDataToMain(keys, this.messKey, this.row);
  880. },
  881. utilToKey(key, name, data, messName) {
  882. if (key == name) {
  883. this.setDataToMain(data[key], messName, this.row)
  884. }
  885. },
  886. //判断是否有值,有值赋值
  887. setDataToMain(data, key, row) {
  888. if (!!data && data != '--') {
  889. if (!!this.tableData[row]) {
  890. tools.setDataForKey(this.tableData[row], key, data);
  891. this.handleUpdataTable([[row, key, null, data]], "edit");
  892. } else {
  893. this.tableData[row] = {};
  894. tools.setDataForKey(this.tableData[row], key, data);
  895. }
  896. } else {
  897. tools.setDataForKey(this.tableData[row], key, "");
  898. }
  899. },
  900. //未知
  901. setGraphyId(graphyId, assetGroupList) {
  902. this.graphyId = graphyId
  903. this.assetGroupList = assetGroupList
  904. },
  905. },
  906. watch: {
  907. projectId(){
  908. this.main = []
  909. this.mess.deviceId = null
  910. this.page.total = 0
  911. },
  912. showTypes: {
  913. handler(newName, oldName) {
  914. if (newName && newName[0] && newName[0].value) {
  915. this.showType = newName[0].value
  916. } else {
  917. this.showType = ""
  918. }
  919. },
  920. immediate: true,
  921. deep: true
  922. }
  923. }
  924. };
  925. </script>
  926. <style lang="less">
  927. .hanson-bar {
  928. height: 40px;
  929. padding: 5px 0;
  930. font-size: 14px;
  931. overflow: hidden;
  932. margin-top: 0;
  933. line-height: 40px;
  934. .iconfont {
  935. font-size: 12px;
  936. }
  937. }
  938. .add-assets{
  939. .el-dialog__body{
  940. height: 130px;
  941. .die-text{
  942. margin-left: 10px;
  943. font-weight: bold;
  944. clear: both;
  945. padding-top: 25px;
  946. padding-bottom: 10px;
  947. .die-num{
  948. width: 100px;
  949. text-align: center;
  950. display: inline-block;
  951. border-bottom: 1px solid #333;
  952. }
  953. }
  954. }
  955. }
  956. .cancelButtonClass {
  957. width: 180px;
  958. }
  959. </style>