123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691 |
- <template>
- <div id="deviceList">
- <el-row class="right">
- <span style="width:20px;float:left;display:block;height:20px;cursor: pointer;" @click="changeAssetsFalg">
- <i class="el-icon-fa el-icon-fa-compass"></i>
- </span>
- <span style="float:left;">当前选择的设备类型:{{category.name}}</span>
- <div style="width:200px;display:inline-block;text-align:left;color:gray;">
- <span>隐藏自动填充的信息</span>
- <el-checkbox v-model="showTypeFlag" @change="getTableHeader"></el-checkbox>
- </div>
- <span>增加</span>
- <el-input v-model="addNum" style="width:40px;" size="small"></el-input>
- <span>个{{category.name}}</span>
- <el-button @click="handleAddTableRow">增加</el-button>
- </el-row>
- <div class="tableBox">
- <div class="center middle_sty" style="flex:2;" v-show="tableData && !tableData.length">
- <p>
- <i class="icon-wushuju iconfont"></i>
- 暂无数据
- </p>
- </div>
- <div class="tableLeft" v-show="tableData && tableData.length">
- <handson-table ref="table"></handson-table>
- </div>
- </div>
- <el-row class="center">
- <el-button type="primary" size="medium" @click="handleCreateTableData" class="create_button">创建设备</el-button>
- </el-row>
- <!-- 二维码弹窗 -->
- <qrcode :dialog="myDialog" :qrcodeUrl="qrcodeUrl" :addBody="true" ref="qrcode"></qrcode>
- <!-- 型号弹窗 -->
- <firm :mess="{deviceId: firmId}" ref="firm" @changeFirm="firmChange" :dialog="myDialog"></firm>
- <!-- 供应商合同弹窗 -->
- <supply-dialog ref="supply" @change="supplyChange" :id="id" :dialog="myDialog"></supply-dialog>
- <!-- 供应商弹窗 -->
- <supplier-dialog ref="supplier" @changeSupplier="supplierChange" :dialog="myDialog"></supplier-dialog>
- <guarantee-dialog :id="id" ref="guarantee" @change="guaranteeChange" :dialog="myDialog"></guarantee-dialog>
- <upload-files-dialog :read="onlyRead ? true : false" ref="upload" @changeFile="fileChange" :keysArr="filesArr" :dialog="myDialog">
- </upload-files-dialog>
- <upload-img-dialog :read="onlyRead ? true : false" @changeFile="imgChange" :keysArr="imgsArr" :dialog="myDialog"></upload-img-dialog>
- <maintainer-dialog @changeMaintainer="changeMaintainer" ref="maintainer" :dialog="myDialog"></maintainer-dialog>
- <insurer-dialog @changeInsurer="changeInsurer" ref="insurer" :dialog="myDialog"></insurer-dialog>
- <pic-dialog :read="onlyRead ? true : false" :dialog="myDialog" :keysArr="picsArr" @change="changePics"></pic-dialog>
- <system-type :device="category" :dialog="myDialog" :type="onlyRead?'read':'edit'" @change="changeSystemType" :list="systemList"></system-type>
- <details-dialog :iframeSrc="iframeSrc" v-if="myDialog.details" :dialog="myDialog"></details-dialog>
- </div>
- </template>
- <script>
- import tools from "@/utils/scan/tools";
- import handsonUtils from "@/utils/hasontableUtils";
- import showTools from "@/utils/handsontable/notShow";
- import text from "@/utils/handsontable/mainText";
- import session from "@/framework/utils/storage";
- import buildFloor from '@/utils/handsontable/buildFloorData'
- import handsonTable from "@/components/common/handsontable";
- import {
- getDataDictionary,
- createEquip,
- createPropertyData,
- getEquipBelongs,
- getSpaceFloor,
- createEquipAndProperty
- } from "@/api/scan/request";
- import { mapGetters, mapActions } from "vuex";
- import qrcode from "@/components/ledger/lib/qrcode";
- import firm from "@/components/dialogs/list/firm";
- import supplyDialog from "@/components/dialogs/list/supplyDialog";
- import supplierDialog from "@/components/dialogs/list/supplierDialog";
- import maintainerDialog from "@/components/dialogs/list/maintainerDialog";
- import insurerDialog from "@/components/dialogs/list/insurerDialog";
- import guaranteeDialog from "@/components/dialogs/list/guaranteeDialog";
- import uploadFilesDialog from "@/components/dialogs/list/filesDialog";
- import uploadImgDialog from "@/components/dialogs/list/uploadImgDialog";
- import picDialog from "@/components/dialogs/list/picDialog";
- import systemType from "@/components/dialogs/list/systemType";
- export default {
- components: {
- qrcode,
- firm,
- supplyDialog,
- supplierDialog,
- maintainerDialog,
- insurerDialog,
- guaranteeDialog,
- uploadFilesDialog,
- uploadImgDialog,
- picDialog,
- systemType,
- handsonTable
- },
- data() {
- return {
- addNum: 1,
- onlyRead: false,
- tableHeader: [],
- tableData: session.get("deviceAddData")
- ? session.get("deviceAddData").length
- ? session.get("deviceAddData")
- : [{ Checked: 1 }]
- : [{ Checked: 1 }],
- copyTableData: [],
- category: "",
- myDialog: {
- qrcode: false,
- firm: false,
- supply: false,
- supplier: false,
- guarantee: false,
- maintainer: false,
- insurer: false,
- uploadFiles: false,
- uploadImgs: false,
- pic: false,
- addDevice: false,
- systemType: false,
- details: false,
- changeRea: false,
- lookPic: false
- },
- qrcodeUrl: "",
- filesArr: [],
- imgsArr: [],
- picsArr: [],
- systemList: [],
- systemId: null,
- graphyId: null,
- id: 0,
- showTypeFlag: true,
- EquipmentList: [],
- firmId: "",
- buildFloorData: [],
- };
- },
- computed: {
- ...mapGetters("layout", ["projectId", "secret", "userId"])
- },
- created() {
- this.category = this.$route.query;
- buildFloor.getData(this.buildFloorData)
- this.getBelongs();
- this.getTableHeader();
- },
- methods: {
-
- getBelongs() {
- let params = {
- data: {
- Filters: `EquipCode='${this.category.deviceId}'`,
- PageNumber: 1,
- PageSize: 50
- }
- }
- getEquipBelongs(params, res => {
- this.firmId = res.Content[0].Family;
- })
- },
-
- changeAssetsFalg() {
- if (this.floorFlag) {
- this.floorFlag = false
- } else {
- this.$confirm('<p>维护设备所在建筑楼层后,对后续数据影响较大,如业务空间中的所在关系or其他?暂未梳理明白……</p><p>后续要修改设备所属建筑楼层,只能通过模型中的待建模清单操作</p>', '提示', {
- dangerouslyUseHTMLString: true,
- confirmButtonText: '就要维护设备所属建筑楼层',
- cancelButtonText: '暂时不搞了',
- confirmButtonClass: 'confirmButtonClass',
- cancelButtonClass: 'cancelButtonClass'
- }).then(_ => {
- this.floorFlag = true
- this.getTableHeader()
- }).catch(_ => {
- this.$message("取消")
- })
- }
- },
-
- changeArr(arr) {
- return arr.map(item => {
- if (item.floors && item.floors.length) {
- return {
- value: item.id,
- label: item.infos.BuildLocalName,
- children: item.floors.map(i => {
- return {
- value: i.id,
- label: i.infos.FloorLocalName || "未知",
- }
- })
- }
- } else {
- return {
- value: item.id,
- label: item.infos.BuildLocalName,
- children: null,
- isChilren: 1,
- }
- }
- })
- },
-
- async getTableHeader() {
- let params = {
- data: {
- PageNumber: 1,
- PageSize: 500
- },
- type: this.category.deviceId
- };
- await getDataDictionary(params, res => {
- this.tableHeader = res.Content;
- this.initTable();
- });
- },
-
- async handleCreateTableData() {
- let newData = this.tableData.filter(item => {
- let keys = Object.keys(item);
- keys.map(key => {
-
- if (item[key] == "") {
- delete item[key];
- }
- });
- let newK = Object.keys(item)
- if ((item.Checked && newK.length > 1) || (!item.Checked && newK.length)) {
- return item;
- }
- });
- if (!newData.length) {
- this.$message("创建信息为空,请录入信息后再创建!");
- return;
- }
- let flag = false;
- newData.map(item => {
- if (item.Checked && !item.EquipLocalName) {
- flag = true;
- }
-
- if (item.flowBuild) {
- let bid = item.flowBuild.split("-");
- item.BuildingId = item.flowBuild.split("-")[0]
- if (bid[1]) {
- item.FloorId = item.flowBuild.split("-")[1]
- }
- }
-
- if (item.LinkSystem && item.LinkSystem.length) {
- item.SystemList = []
- item.LinkSystem.map(t => {
- item.SystemList.push(t.SysID)
- })
- }
- item.PropertyId = !!item.Checked;
- item.Category = this.category.deviceId;
- })
- if (flag) {
- this.$message.info("存在设备的本地名称为空,请检查")
- return;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- let param = {
- Cascade: [],
- Content: newData
- }
- createEquipAndProperty(param, res => {
- this.$message.success('创建成功')
- session.remove("deviceAddData")
- this.$router.push({
- name: "facilityLedger",
- params: { deviceId: this.category.deviceId }
- });
- })
- },
-
- handleDeleteTableRow() {
- this.$message.success("删除成功");
- this.formaTableData();
- },
-
- handleAddTableRow() {
- let addRowLength = this.addNum;
- for (let i = 0; i < addRowLength; i++) {
- this.tableData.push({ Checked: 1 });
- }
- this.initTable();
- this.formaTableData();
- },
-
- handleUpdataTable(changeData, source) {
- this.formaTableData();
- },
-
- formaTableData() {
- let newData = this.tableData.filter(item => {
- let keys = Object.keys(item);
- keys.map(key => {
-
- if (item[key] == "") {
- delete item[key];
- }
- });
- if (keys.length && Object.keys(item).length) {
- return item;
- }
- });
- session.set("deviceAddData", newData);
- },
-
- formatHeaderData(list) {
- let arr = tools.copyArr(list);
- let showType = this.showTypeFlag ? 'partInfo' : 'all';
- let data = showTools.headerTextFilter(arr, 'equipment', this.onlyRead, showType, true);
- data.unshift("同时创建资产", "所属系统实例");
- if (this.floorFlag) {
- data.splice(1, 0, "所属建筑楼层")
- }
- return data;
- },
- formatHeaderType(list) {
-
- let arr = tools.copyArr(list);
- let showType = this.showTypeFlag ? 'partInfo' : 'all';
- let data = showTools.headerTypeFilter(arr, 'equipment', this.onlyRead, showType, true);
- data.unshift({
- type: "checkbox",
- checkedTemplate: 1,
- uncheckedTemplate: 0,
- data: "Checked",
- label: {
- position: "after"
- }
- }, {
- data: "LinkSystem",
- renderer: text.systemList,
- readOnly: true
- });
- if (this.floorFlag) {
- data.splice(1, 0, {
- data: "flowBuild",
- renderer: tools.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
-
- data: this.buildFloorData
- }
- })
- }
- return data;
- },
- initTable() {
-
- let settings = {
- data: this.tableData,
- colHeaders: this.formatHeaderData(this.tableHeader),
- columns: this.formatHeaderType(this.tableHeader),
- rowHeights: 30,
- maxRows: this.tableData.length,
- contextMenu: {
- items: {
- remove_row: {
- name: "删除设备"
- }
- }
- },
-
- afterChange: this.handleUpdataTable,
- afterFilter: this.trimmedRows,
- afterRemoveRow: this.handleDeleteTableRow,
- afterOnCellMouseDown: this.handleTdClick
- };
- this.$nextTick(() => {
- this.tableExample = this.$refs.table.init(settings);
- });
- },
-
- array_diff(a, b) {
- for (var i = 0; i < b.length; i++) {
- for (var j = 0; j < a.length; j++) {
- if (a[j] == b[i]) {
- a.splice(j, 1);
- j = j - 1;
- }
- }
- }
- return a;
- },
-
- firmChange(data) {
- tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Brand", data.brand)
- tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Specification", data.name)
- tools.setDataForKey(this.tableData[this.row], "DPManufacturerID", data.venderId)
- },
- supplyChange(data) {
- let changeData = { id: data };
- this.utilToKey("id", "id", changeData, "SupplierContractID");
- },
-
- supplierChange(data) {
- tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.Supplier", data.name)
- tools.setDataForKey(this.tableData[this.row], "DPSupplierID", data.venderId)
- },
-
- guaranteeChange(data) {
- for (let key in data) {
- this.utilToKey(key, "insuranceNo", data, "InsuranceNum");
- if (key == "contractFile") {
- if (!!data[key]) {
- data[key] = [data[key]];
- }
- }
- this.utilToKey(key, "contractFile", data, "InsuranceFile");
- }
- },
-
- fileChange(keys) {
- this.setDataToMain(keys, this.messKey, this.row);
- },
-
- imgChange(keys) {
- this.setDataToMain(keys, this.messKey, this.row);
- },
-
- changeMaintainer(data) {
- tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.Maintainer", data.name)
- tools.setDataForKey(this.tableData[this.row], "DPMaintainerID", data.venderId)
- },
-
- changeInsurer(data) {
- tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.Insurer", data.name)
- tools.setDataForKey(this.tableData[this.row], "DPInsurerID", data.venderId)
- },
-
- changePics(keys) {
- this.setDataToMain(keys, this.messKey, this.row);
- },
-
- changeSystemType(data) {
- tools.setDataForKey(this.tableData[this.row], "LinkSystem", data)
- },
-
- handleTdClick(el, rowArr) {
-
- if (rowArr.row < 0) {
- return;
- }
-
- let trimmedArr = this.trimmedRows();
-
- let isSort = this.tableExample.getPlugin("columnSorting").isSorted();
- if (trimmedArr.length && isSort) {
- let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
- .__arrayMap;
- let infos = this.tableData[trimmedArr[sortArr[rowArr.row]]];
- this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col });
- } else if (isSort) {
-
- let sortArr = this.tableExample.getPlugin("columnSorting").rowsMapper
- .__arrayMap;
- let infos = this.tableData[sortArr[rowArr.row]];
- this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col });
- } else if (trimmedArr.length) {
- let infos = this.tableData[trimmedArr[rowArr.row]];
- this.getInfors(infos, { row: trimmedArr[rowArr.row], col: rowArr.col });
- } else {
- let infos = this.tableData[rowArr.row];
- this.getInfors(infos, rowArr);
- }
- },
-
- trimmedRows() {
- var plugin = this.tableExample.getPlugin("trimRows").trimmedRows;
- let dataLength = this.tableData.length;
- let dataArr = new Array();
- for (let i = 0; i < dataLength; i++) {
- dataArr.push(i);
- }
- if (plugin.length <= 0) {
- dataArr = undefined;
- } else {
- dataArr = this.array_diff(dataArr, plugin);
- }
- return dataArr || [];
- },
- getInfors(infos, row) {
- let val = this.tableExample.colToProp(row.col);
- switch (val) {
-
- case 'caozuo':
-
- this.$message("开发中...")
- break;
-
- case 'EquipQRCode':
- this.qrcodeUrl = this.tableData[row.row].EquipQRCode;
- if (!!this.qrcodeUrl) {
- this.myDialog.qrcode = true;
- } else {
- this.$message("此设备没有设备二维码");
- }
- break;
-
- case 'LinkSystem':
- if (!this.onlyRead) {
- this.systemList = this.tableData[row.row].LinkSystem || [];
- this.myDialog.systemType = true;
- }
- break;
-
- case 'LinkEquipLocalName':
- if (this.linkNameFalg) {
- this.myDialog.changeRea = true;
- }
- break;
-
- case 'DPManufacturerID':
- if (!this.onlyRead) {
- this.myDialog.firm = true;
- }
- break;
-
- case 'DPSupplierID':
- if (!this.onlyRead) {
- this.myDialog.supplier = true;
- }
- break;
-
- case 'DPMaintainerID':
- if (!this.onlyRead) {
- this.myDialog.maintainer = true;
- }
- break;
-
- case 'DPInsurerID':
- if (!this.onlyRead) {
- this.myDialog.insurer = true;
- }
- break;
-
- case 'LedgerParam.SupplyPurchase.SupplierContractID':
- if (!this.onlyRead) {
- let ContractIDflag = null;
- let DPSdata = this.tableData[row.row].DPSupplierID;
- if (DPSdata) {
- ContractIDflag = DPSdata.split("-")[0];
- }
- if (!!ContractIDflag) {
- this.id = ContractIDflag;
- this.myDialog.supply = true;
- } else {
- this.$message("请先选择供应商");
- }
- }
- break;
-
- case 'LedgerParam.InsuranceDoc.InsuranceNum':
- if (!this.onlyRead) {
- let DPInsurerIDflag = null;
- let DPIdata = this.tableData[row.row].DPInsurerID;
- if (DPIdata) {
- DPInsurerIDflag = DPIdata.split("-")[0];
- }
- if (!!DPInsurerIDflag) {
- this.id = DPInsurerIDflag;
- this.myDialog.guarantee = true;
- } else {
- this.$message("请先选择保险商");
- }
- }
- break;
-
- case 'LedgerParam.InsuranceDoc.InsuranceFile':
- case 'LedgerParam.PhotoDoc.Archive':
- case 'LedgerParam.Siteinstall.CheckReport':
- let IPSdata = tools.dataForKey(this.tableData[row.row], val);
- this.filesArr = IPSdata ? IPSdata : [];
- this.myDialog.uploadFiles = true;
- break;
-
- case 'LedgerParam.Siteinstall.InstallPic':
- case 'LedgerParam.Siteinstall.InstallDrawing':
- case 'LedgerParam.PhotoDoc.Nameplate':
- case 'LedgerParam.PhotoDoc.Drawing':
- let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
- this.imgsArr = SSPPdata ? SSPPdata : [];
- this.myDialog.uploadImgs = true;
- break;
-
- case 'LedgerParam.PhotoDoc.Pic':
- let Pdata = tools.dataForKey(this.tableData[row.row], val);
- this.picsArr = Pdata ? Pdata : [];
- this.myDialog.pic = true;
- break;
-
- case 'Count':
- if (this.onlyRead) {
- this.$router.push({ path: '/ledger/parts', query: { deviceId: infos.EquipID } });
- } else {
- this.$router.push({ path: '/ledger/partsmanage', query: { deviceId: infos.EquipID, typeId: this.mess.deviceId } });
- }
- break;
- default:
- break;
- }
- this.row = row.row;
- this.messKey = val;
- },
- utilToKey(key, name, data, messName) {
- if (key == name) {
- this.setDataToMain(data[key], messName, this.row);
- }
- },
-
- setDataToMain(data, key, row) {
- if (!!data && data != "--") {
- if (!!this.tableData[row]) {
-
- tools.setDataForKey(this.tableData[row], key, data)
-
- } else {
- this.tableData[row] = {};
- tools.setDataForKey(this.tableData[row], key, data)
- }
- } else {
- tools.setDataForKey(this.tableData[row], key, "")
- }
- }
- }
- };
- </script>
- <style lang="less" scoped>
- #deviceList {
- overflow: hidden;
- height: 100%;
- background-color: #fff;
- padding: 10px;
- position: relative;
- .right {
- background: #fff;
- }
- .search-header {
- overflow: hidden;
- padding: 0 10px 10px 10px;
- border-bottom: 1px solid #bcbcbc;
- }
- .tableBox {
- display: flex;
- height: calc(100% - 100px);
- margin-top: 10px;
- .tableLeft {
- flex: 1;
- }
- }
- .create_button {
- margin-top: 10px;
- }
- }
- </style>
|