assets.vue 37 KB

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