assets.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970
  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.tableData && this.tableData.length) {
  249. // if (this.onlyRead) {
  250. // this.getBatch(this.tableData)
  251. // }
  252. this.initTable()
  253. }
  254. })
  255. }
  256. },
  257. //获取动态参数
  258. getBatch(data) {
  259. let param = {
  260. secret: this.secret,
  261. ProjId: this.projectId,
  262. data: {
  263. criterias: []
  264. }
  265. };
  266. this.tableHeader.map(head => {
  267. if (
  268. head.InputMode == "L" ||
  269. head.InputMode == "L1" ||
  270. head.InputMode == "L2" ||
  271. head.InputMode == "M"
  272. ) {
  273. data.map(item => {
  274. let cur = tools.dataForKey(item, head.Path);
  275. if (cur) {
  276. param.data.criterias.push({
  277. id: item.EquipID,
  278. code: head.InfoPointCode
  279. });
  280. }
  281. });
  282. }
  283. });
  284. if (param.data.criterias.length) {
  285. BeatchQueryParam(param, res => {
  286. this.tableData = data.map(item => {
  287. res.Content.map(child => {
  288. if (item.EquipID == child.id) {
  289. if (child.data || child.data == 0) {
  290. this.tableHeader.map(head => {
  291. if (head.InfoPointCode == child.code) {
  292. tools.setDataForKey(item, head.Path, child.data);
  293. }
  294. });
  295. } else {
  296. this.tableHeader.map(head => {
  297. if (head.InfoPointCode == child.code) {
  298. tools.setDataForKey(
  299. item,
  300. head.Path,
  301. child.error ? "表号功能号格式错误" : "表号功能号不存在"
  302. );
  303. }
  304. });
  305. }
  306. }
  307. });
  308. return item;
  309. });
  310. this.hot.loadData(this.tableData);
  311. });
  312. }
  313. },
  314. //撤回
  315. undo() {
  316. this.hot.undo();
  317. },
  318. //刷新-switch改变
  319. reset() {
  320. this.getTableData();
  321. },
  322. //添加资产
  323. addDevice() {
  324. this.myDialog.addDevice = true
  325. if (this.mess.deviceId) {
  326. this.$nextTick(() => {
  327. this.$refs.cascader.setValue([this.mess.deviceId])
  328. this.addData.Family = this.mess.deviceId
  329. this.numParams.Family = this.mess.deviceId
  330. })
  331. }
  332. },
  333. //手动创建
  334. toAddDevice() {
  335. if (this.addData.Family) {
  336. this.$router.push({
  337. path: "/ledger/propertyadd",
  338. query: this.addData
  339. });
  340. } else {
  341. this.$message("请选择设备族")
  342. }
  343. },
  344. //显示通过部件或设备创建资产页
  345. toAddbyDie() {
  346. if (this.addData.Family) {
  347. this.showAddByDie = true
  348. this.$nextTick(() => {
  349. this.$refs.dieCascader.getAllData()
  350. })
  351. } else {
  352. this.$message("请选择设备族")
  353. }
  354. },
  355. //格式化条件
  356. formatFilter() {
  357. let param = {
  358. Filters: `category='${this.numParams.category}';PropertyId isNull`
  359. }
  360. if (this.numParams.buildId == "noKnow") {
  361. param.Filters += `;buildingId isNull`
  362. } else if (this.numParams.buildId && this.numParams.buildId != "all") {
  363. param.Filters += `;buildingId='${this.numParams.buildId}'`
  364. }
  365. if (this.numParams.floorId == "noKnow") {
  366. param.Filters += `;floorId isNull`
  367. } else if (this.numParams.floorId && this.numParams.floorId != "all") {
  368. param.Filters += `;floorId='${this.numParams.floorId}'`
  369. }
  370. return param
  371. },
  372. //批量添加
  373. createByDie() {
  374. let param = this.formatFilter()
  375. createPropertys(param, res => {
  376. this.myDialog.addDevice = false
  377. this.$emit('getJson',{code: this.numParams.Family})
  378. this.$message.success("创建成功!")
  379. })
  380. },
  381. //获取未关联资产的设备或部件数量
  382. getNumDie() {
  383. let param = this.formatFilter()
  384. countPartsDie(param, res => {
  385. this.dieNum = res.Count
  386. })
  387. },
  388. //查看详情
  389. toDetaiPage() {
  390. this.$router.push({
  391. path: "/ledger/addPropertys",
  392. query: this.numParams
  393. })
  394. },
  395. //选择设备类型-添加资产
  396. changeCader(val) {
  397. this.addData.Family = val.code
  398. this.addData.name = val.facility
  399. this.numParams.Family = val.code
  400. },
  401. //选择设备或部件
  402. changeDevice(val) {
  403. if(val.code) {
  404. this.numParams.category = val.code
  405. } else {
  406. this.numParams.category = ''
  407. }
  408. this.getNumDie()
  409. },
  410. //选择建筑楼层
  411. changeFloor(value) {
  412. if (value[0]) {
  413. this.numParams.buildId = value[0]
  414. }
  415. if (value[1]) {
  416. this.numParams.floorId = value[1]
  417. } else {
  418. this.numParams.floorId = ''
  419. }
  420. this.getNumDie()
  421. },
  422. //下载
  423. download() {
  424. if (!this.onlyRead) {
  425. if (!!this.hot) {
  426. let fileName = this.mess.name + "-页数:" + this.page.currentPage + "-个数:" + this.tableData.length + "-总个数:" + this.page.total
  427. this.hot.getPlugin('exportFile').downloadFile("csv", { filename: fileName, columnHeaders: true, exportHiddenRows: true, exportHiddenColumns: true, rowHeaders: true })
  428. } else {
  429. this.$message("请确定存在表格")
  430. }
  431. } else {
  432. this.$message("下载需在编辑状态下")
  433. }
  434. },
  435. //格式化表头
  436. formatHeaderData(list) {
  437. let arr = tools.copyArr(list)
  438. let data = showTools.headerTextFilter(arr, 'property', this.onlyRead, this.showType, true)
  439. data.unshift("操作", "当前关联的设备")
  440. if (this.showType == "all") {
  441. data.splice(4, 0, "所属建筑楼层")
  442. }
  443. return data
  444. },
  445. //格式化表内容
  446. formatHeaderType(list) {
  447. let arr = tools.copyArr(list)
  448. let data = showTools.headerTypeFilter(arr, 'property', this.onlyRead, this.showType, true)
  449. data.unshift(
  450. {
  451. data: "caozuo",
  452. renderer: tools.lookDetails
  453. }, {
  454. data: "LinkEquipLocalName",
  455. renderer: tools.LinkEquipLocalName,
  456. readOnly: true
  457. }
  458. )
  459. if (this.showType == "all") {
  460. data.splice(4, 0, {
  461. data: "flowBuild",
  462. renderer: tools.customDropdownRenderer,
  463. editor: "chosen",
  464. chosenOptions: {
  465. data: this.buildFloorData
  466. },
  467. readOnly: this.onlyRead
  468. })
  469. }
  470. return data
  471. },
  472. //初始化插件
  473. initTable() {
  474. var container = document.getElementById("handsontable");
  475. let winHeight = document.documentElement.clientHeight;
  476. if (this.hot) {
  477. this.hot.destroy();
  478. this.hot = null;
  479. }
  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. }, keyList = []
  605. //生成要修改字段列表
  606. change.map(item => {
  607. let key = item[1].split(".")[0]
  608. if (item[1] && keyList.indexOf(key) == -1) {
  609. keyList.push(key)
  610. }
  611. if (item[1] && item[3] == "" && param.Projection.indexOf(key) == -1) {
  612. param.Projection.push(key)
  613. }
  614. if (key == "flowBuild" && keyList.indexOf(key) == -1) {
  615. keyList.push("BuildingId","FloorId")
  616. param.Projection.push("BuildingId","FloorId")
  617. }
  618. })
  619. //生成对应修改数据
  620. data.map((item, index) => {
  621. keyList.map(value => {
  622. if (value == "BuildingId") {
  623. let itemData = tools.dataForKey(item, "flowBuild")
  624. if (itemData == "") {
  625. tools.setDataForKey(item, "BuildingId", null)
  626. tools.setDataForKey(item, "FloorId", null)
  627. } else {
  628. let BuildingId = itemData.split("-")[0]
  629. let FloorId = itemData.split("-")[1]
  630. if (BuildingId && FloorId) {
  631. tools.setDataForKey(item, "BuildingId", BuildingId)
  632. tools.setDataForKey(item, "FloorId", FloorId)
  633. } else if (BuildingId && !FloorId) {
  634. tools.setDataForKey(item, "BuildingId", BuildingId)
  635. tools.setDataForKey(item, "FloorId", null)
  636. }
  637. }
  638. } else {
  639. let itemData = tools.dataForKey(item, value)
  640. tools.setDataForKey(item, value, itemData == "" ? null : itemData)
  641. }
  642. });
  643. param.Content.push(item)
  644. })
  645. updateProperty(param, res => { })
  646. },
  647. //修改资产类型
  648. // changeCader() {
  649. // if (this.mess.deviceId) {
  650. // let param = {
  651. // data: {
  652. // Filters: `EquipCode='${this.mess.deviceId}'`,
  653. // PageNumber: 1,
  654. // PageSize: 50
  655. // }
  656. // }
  657. // getEquipBelongs(param, res => {
  658. // if (res.Content.length) {
  659. // this.deviceType.assetType = res.Content[0].Family
  660. // this.deviceType.assetName = res.Content[0].FamilyName
  661. // }
  662. // })
  663. // }
  664. // },
  665. //获取到了正确的信息
  666. getInfors(infos, row, el) {
  667. let val = this.hot.colToProp(row.col);
  668. this.row = row.row;
  669. this.messKey = val;
  670. switch (val) {
  671. //操作
  672. case 'caozuo':
  673. // window.open(`http://adm.sagacloud.cn:8058/spread?id=${infos.EquipID}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
  674. this.$message("开发中...")
  675. break;
  676. //资产二维码图片
  677. case 'EquipQRCode':
  678. this.qrcodeUrl = this.tableData[row.row].EquipQRCode;
  679. if (!!this.qrcodeUrl) {
  680. this.myDialog.qrcode = true;
  681. } else {
  682. this.$message("此资产没有资产二维码");
  683. }
  684. break;
  685. //关联系统
  686. case 'LinkSystem':
  687. if (!this.onlyRead) {
  688. this.curDevice = infos.EquipID;
  689. this.systemList = this.tableData[row.row].LinkSystem || [];
  690. this.myDialog.systemType = true;
  691. }
  692. break;
  693. //关联资产
  694. case 'LinkEquipLocalName':
  695. if (this.linkNameFalg) {
  696. this.myDialog.changeRea = true;
  697. }
  698. break;
  699. //品牌型号弹窗
  700. case 'DPManufacturerID':
  701. if (!this.onlyRead) {
  702. this.myDialog.firm = true;
  703. }
  704. break;
  705. //供应商信息弹窗
  706. case 'DPSupplierID':
  707. if (!this.onlyRead) {
  708. this.myDialog.supplier = true;
  709. }
  710. break;
  711. //维修商信息弹窗
  712. case 'DPMaintainerID':
  713. if (!this.onlyRead) {
  714. this.myDialog.maintainer = true;
  715. }
  716. break;
  717. //保险公司信息
  718. case 'DPInsurerID':
  719. if (!this.onlyRead) {
  720. this.myDialog.insurer = true;
  721. }
  722. break;
  723. //供应合同编号
  724. case 'LedgerParam.SupplyPurchase.SupplierContractID':
  725. if (!this.onlyRead) {
  726. let ContractIDflag = null;
  727. let DPSdata = this.tableData[row.row].DPSupplierID;
  728. if (DPSdata) {
  729. ContractIDflag = DPSdata.split("-")[0];
  730. }
  731. if (!!ContractIDflag) {
  732. this.id = ContractIDflag;
  733. this.myDialog.supply = true;
  734. } else {
  735. this.$message("请先选择供应商");
  736. }
  737. }
  738. break;
  739. //保险单号
  740. case 'LedgerParam.InsuranceDoc.InsuranceNum':
  741. if (!this.onlyRead) {
  742. let DPInsurerIDflag = null;
  743. let DPIdata = this.tableData[row.row].DPInsurerID;
  744. if (DPIdata) {
  745. DPInsurerIDflag = DPIdata.split("-")[0];
  746. }
  747. if (!!DPInsurerIDflag) {
  748. this.id = DPInsurerIDflag;
  749. this.myDialog.guarantee = true;
  750. } else {
  751. this.$message("请先选择保险商");
  752. }
  753. }
  754. break;
  755. //保险文件--资产文档--安装质检报告
  756. case 'LedgerParam.InsuranceDoc.InsuranceFile':
  757. case 'LedgerParam.PhotoDoc.Archive':
  758. case 'LedgerParam.Siteinstall.CheckReport':
  759. let IPSdata = tools.dataForKey(this.tableData[row.row], val);
  760. this.filesArr = IPSdata ? IPSdata : [];
  761. this.myDialog.uploadFiles = true;
  762. break;
  763. //安装照片--安装图纸--资产铭牌照片--资产图纸
  764. case 'LedgerParam.Siteinstall.InstallPic':
  765. case 'LedgerParam.Siteinstall.InstallDrawing':
  766. case 'LedgerParam.PhotoDoc.Nameplate':
  767. case 'LedgerParam.PhotoDoc.Drawing':
  768. let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
  769. this.imgsArr = SSPPdata ? SSPPdata : [];
  770. this.myDialog.uploadImgs = true;
  771. break;
  772. //资产照片
  773. case 'LedgerParam.PhotoDoc.Pic':
  774. let Pdata = tools.dataForKey(this.tableData[row.row], val);
  775. this.picsArr = Pdata ? Pdata : [];
  776. this.myDialog.pic = true;
  777. break;
  778. //包含的部件字段
  779. case 'Count':
  780. if (this.onlyRead) {
  781. this.$router.push({ path: '/ledger/parts', query: { deviceId: infos.EquipID } });
  782. } else {
  783. this.$router.push({ path: '/ledger/partsmanage', query: { deviceId: infos.EquipID, typeId: this.mess.deviceId } });
  784. }
  785. break;
  786. default:
  787. break;
  788. }
  789. },
  790. //获取被筛选掉的行号
  791. trimmedRows() {
  792. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  793. let dataLength = this.tableData.length;
  794. let dataArr = new Array();
  795. for (let i = 0; i < dataLength; i++) {
  796. dataArr.push(i);
  797. }
  798. if (plugin.length <= 0) {
  799. dataArr = undefined;
  800. } else {
  801. dataArr = this.array_diff(dataArr, plugin);
  802. }
  803. return dataArr || [];
  804. },
  805. //去除数组中相同的元素
  806. array_diff(a, b) {
  807. for (var i = 0; i < b.length; i++) {
  808. for (var j = 0; j < a.length; j++) {
  809. if (a[j] == b[i]) {
  810. a.splice(j, 1);
  811. j = j - 1;
  812. }
  813. }
  814. }
  815. return a;
  816. },
  817. //如果选择供应商之后
  818. supplierChange(data) {
  819. tools.setDataForKey(this.tableData[this.row], "DPSupplierID", data.venderId)
  820. tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.Supplier", data.name)
  821. this.handleUpdataTable([[this.row, "DPSupplierID", null, data.venderId]], "edit")
  822. this.handleUpdataTable([[this.row, "LedgerParam.SupplyPurchase.Supplier", null, data.name]], "edit")
  823. },
  824. //供应合同编号
  825. supplyChange(data) {
  826. tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.SupplierContractID", { id: data })
  827. },
  828. //保险单号-保险文件
  829. guaranteeChange(data) {
  830. for (let key in data) {
  831. this.utilToKey(key, "insuranceNo", data, "InsuranceNum")
  832. if (key == "contractFile") {
  833. if (!!data[key]) {
  834. data[key] = [data[key]]
  835. }
  836. }
  837. this.utilToKey(key, "contractFile", data, "InsuranceFile")
  838. }
  839. },
  840. //选择型号修改
  841. firmChange(data) {
  842. tools.setDataForKey(this.tableData[this.row], "DPManufacturerID", data.venderId)
  843. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Brand", data.brand)
  844. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Specification", data.name)
  845. this.handleUpdataTable([[this.row, "DPManufacturerID", null, data.venderId]], "edit")
  846. this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Brand", null, data.brand]], "edit")
  847. this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Specification", null, data.name]], "edit")
  848. },
  849. //保险商变更
  850. changeInsurer(data) {
  851. tools.setDataForKey(this.tableData[this.row], "DPInsurerID", data.venderId)
  852. tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.Insurer", data.name)
  853. this.handleUpdataTable([[this.row, "DPInsurerID", null, data.venderId]], "edit")
  854. this.handleUpdataTable([[this.row, "LedgerParam.InsuranceDoc.Insurer", null, data.name]], "edit")
  855. },
  856. //维修商变更
  857. changeMaintainer(data) {
  858. tools.setDataForKey(this.tableData[this.row], "DPMaintainerID", data.venderId)
  859. tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.Maintainer", data.name)
  860. this.handleUpdataTable([[this.row, "DPMaintainerID", null, data.venderId]], "edit")
  861. this.handleUpdataTable([[this.row, "LedgerParam.OperationMainte.Maintainer", null, data.name]], "edit")
  862. },
  863. //修改关联的资产
  864. changeProperty(val) {
  865. this.setDataToMain(val.PropertyId, 'PropertyId', this.row);
  866. this.setDataToMain(val.LinkEquipLocalName, 'LinkEquipLocalName', this.row);
  867. },
  868. //上传文件弹窗触发事件
  869. fileChange(keys) {
  870. this.setDataToMain(keys, this.messKey, this.row);
  871. },
  872. //上传图片弹窗触发事件
  873. imgChange(keys) {
  874. this.setDataToMain(keys, this.messKey, this.row);
  875. },
  876. //关联系统更改
  877. changeSystemType(data) {
  878. tools.setDataForKey(this.tableData[this.row], "LinkSystem", data)
  879. },
  880. //资产图片弹窗改变事件
  881. changePics(keys) {
  882. this.setDataToMain(keys, this.messKey, this.row);
  883. },
  884. utilToKey(key, name, data, messName) {
  885. if (key == name) {
  886. this.setDataToMain(data[key], messName, this.row)
  887. }
  888. },
  889. //判断是否有值,有值赋值
  890. setDataToMain(data, key, row) {
  891. if (!!data && data != '--') {
  892. if (!!this.tableData[row]) {
  893. tools.setDataForKey(this.tableData[row], key, data);
  894. this.handleUpdataTable([[row, key, null, data]], "edit");
  895. } else {
  896. this.tableData[row] = {};
  897. tools.setDataForKey(this.tableData[row], key, data);
  898. }
  899. } else {
  900. tools.setDataForKey(this.tableData[row], key, "");
  901. }
  902. },
  903. //未知
  904. setGraphyId(graphyId, assetGroupList) {
  905. this.graphyId = graphyId
  906. this.assetGroupList = assetGroupList
  907. },
  908. },
  909. watch: {
  910. projectId(){
  911. this.main = []
  912. this.mess.deviceId = null
  913. this.page.total = 0
  914. },
  915. showTypes: {
  916. handler(newName, oldName) {
  917. if (newName && newName[0] && newName[0].value) {
  918. this.showType = newName[0].value
  919. } else {
  920. this.showType = ""
  921. }
  922. },
  923. immediate: true,
  924. deep: true
  925. }
  926. }
  927. };
  928. </script>
  929. <style lang="less">
  930. .hanson-bar {
  931. height: 40px;
  932. padding: 5px 0;
  933. font-size: 14px;
  934. overflow: hidden;
  935. margin-top: 0;
  936. line-height: 40px;
  937. .iconfont {
  938. font-size: 12px;
  939. }
  940. }
  941. .add-assets{
  942. .el-dialog__body{
  943. height: 130px;
  944. .die-text{
  945. margin-left: 10px;
  946. font-weight: bold;
  947. clear: both;
  948. padding-top: 25px;
  949. padding-bottom: 10px;
  950. .die-num{
  951. width: 100px;
  952. text-align: center;
  953. display: inline-block;
  954. border-bottom: 1px solid #333;
  955. }
  956. }
  957. }
  958. }
  959. .cancelButtonClass {
  960. width: 180px;
  961. }
  962. </style>