123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762 |
- <template>
- <div id="deviceList">
- <el-row class="right">
- <span style="float: left">当前选择的设备类型:{{ category.name }}</span>
- <el-select
- v-model="showType"
- @change="initTable"
- style="width: 125px; margin-right: 10px; vertical-align: bottom"
- >
- <el-option
- v-for="item in showTypes"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- ></el-option>
- </el-select>
- <span>增加</span>
- <el-input-number
- v-model="addNum"
- :controls="false"
- style="width: 50px"
- :min="1"
- :max="50"
- ></el-input-number>
- <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"
- :disabled="createDisable"
- >创建设备</el-button
- >
- </el-row>
- <!-- 多选枚举类型维护 -->
- <menum
- :dialog="myDialog"
- :updateInfoData="updateInfoData"
- :updateInput="updateInput"
- @change="handleChangeMenum"
- ></menum>
- <!-- 二维码弹窗 -->
- <qrcode
- :dialog="myDialog"
- :qrcodeUrl="qrcodeUrl"
- :addBody="true"
- ref="qrcode"
- ></qrcode>
- <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>
- <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/old-adm/scan/tools";
- import showTools from "@/utils/old-adm/handsontable/notShow";
- import text from "@/utils/old-adm/handsontable/mainText";
- import storage from "@/utils/storageUtil";
- import BuildController from "@/controller/old-adm/buildController";
- import handsonTable from "@/components/old-adm/common/handsontable";
- import ScanController from "@/controller/old-adm/ScanController";
- import Dic from "@/controller/old-adm/dicController";
- import { mapGetters } from "vuex";
- import qrcode from "@/components/old-adm/ledger/components/lib/qrcode";
- import uploadFilesDialog from "@/components/old-adm/dialogs/list/filesDialog";
- import uploadImgDialog from "@/components/old-adm/dialogs/list/uploadImgDialog";
- import picDialog from "@/components/old-adm/dialogs/list/picDialog";
- import menum from "@/components/old-adm/dialogs/list/menum";
- import systemType from "@/components/old-adm/dialogs/list/systemType";
- export default {
- components: {
- qrcode,
- uploadFilesDialog,
- uploadImgDialog,
- picDialog,
- systemType,
- handsonTable,
- menum,
- },
- data() {
- return {
- addNum: 1,
- onlyRead: false,
- showTypes: [
- { value: "Visible", label: "只看需交付的" },
- { value: "all", label: "全部" },
- ],
- tableHeader: [],
-
-
-
-
-
- tableData: storage.get("deviceAddData")
- ? storage.get("deviceAddData").length
- ? storage.get("deviceAddData")
- : []
- : [],
- copyTableData: [],
- category: "",
- myDialog: {
- qrcode: false,
- uploadFiles: false,
- uploadImgs: false,
- pic: false,
- addDevice: false,
- systemType: false,
- details: false,
- changeRea: false,
- lookPic: false,
- menum: false,
- },
- inputMap: {
- flowBuild: {
- editable: true,
- code: "flowBuild",
- name: "建筑楼层",
- path: "flowBuild",
- category: "STATIC",
- dataType: "ENUM",
- },
- },
- qrcodeUrl: "",
- filesArr: [],
- imgsArr: [],
- picsArr: [],
- systemList: [],
- systemId: null,
- graphyId: null,
- id: 0,
- showType: this.$route.query.showType,
- EquipmentList: [],
- firmId: "",
- buildFloorData: [],
- floorFlag: true,
- createDisable: false,
- updateInfoData: {},
- updateInfoPoint: "",
- updateInput: "",
- };
- },
- computed: {
- ...mapGetters("layout", ["projectId", "secret", "userId"]),
- },
- created() {
- this.category = this.$route.query;
- BuildController.getData(this.buildFloorData);
- this.getBelongs();
- this.getTableHeader();
- },
- methods: {
-
- getBelongs() {
- let params = {
- data: {
- filters: `equipCode='${this.category.deviceId}'`,
- pageNumber: 1,
- pageSize: 50,
- },
- };
- ScanController.getEquipBelongs(params).then((res) => {
- if (res.content.length) {
- this.firmId = res.content[0].family;
- }
- });
- },
-
- 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 = {
- orders: "sort asc, name desc",
- pageNumber: 1,
- pageSize: 1000,
- type: this.category.deviceId,
- };
- await Dic.getDataDictionary(params, (res) => {
- this.tableHeader = res.content;
- this.tableHeader.forEach((item) => {
- if (item.path) {
- this.inputMap[item.path] = item;
- }
- });
- 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.localName) {
- 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.id);
- });
- }
-
-
- item.classCode = this.category.deviceId;
- });
- if (flag) {
- this.$message.info("存在设备的本地名称为空,请检查");
- return;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.createDisable = true;
-
- let param = {
- cascade: [],
- content: newData,
- };
- ScanController.createEquipAndProperty(param).then((res) => {
- this.createDisable = false;
- this.$message.success("创建成功");
- storage.remove("deviceAddData");
- this.$router.push({
- name: "facilityLedger",
- params: {
- deviceId: this.category.deviceId,
- facility: this.category.name,
- },
- });
- });
- },
-
- handleDeleteTableRow(a, b, c, d) {
- if (d && d === "ContextMenu.removeRow") {
- this.$message.success("删除成功");
- this.formaTableData();
- }
- },
-
- handleAddTableRow() {
- let addRowLength = this.addNum;
- for (let i = 0; i < addRowLength; i++) {
-
- this.tableData.push({});
- }
- this.initTable();
- this.formaTableData();
- },
-
- handleUpdataTable(changeData, source) {
- if (!this.onlyRead && source != "ObserveChanges.change") {
- 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;
- }
- });
- storage.set("deviceAddData", newData);
- },
-
- formatHeaderData(list) {
- let arr = tools.copyArr(list);
- let data = showTools.headerTextFilter(
- arr,
- "equipment",
- this.onlyRead,
- this.showType,
- true
- );
-
- data.unshift("所属系统实例");
- if (this.floorFlag) {
- data.splice(1, 0, "所属建筑楼层");
- }
- return data;
- },
- formatHeaderType(list) {
-
- let arr = tools.copyArr(list);
- let data = showTools.headerTypeFilter(
- arr,
- "equipment",
- this.onlyRead,
- this.showType,
- true
- );
- data.unshift(
-
-
-
-
-
-
-
-
-
- {
- 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,
- fillHandle: "vertical",
- maxRows: this.tableData.length,
- contextMenu: this.onlyRead
- ? false
- : {
- 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;
- },
-
- fileChange(keys) {
- this.setDataToMain(keys, this.messKey, this.row);
- },
-
- imgChange(keys) {
- this.setDataToMain(keys, this.messKey, this.row);
- },
-
- 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);
- let inputData = this.inputMap[val];
- this.row = row.row;
- this.messKey = val;
- switch (val) {
-
- case "caozuo":
-
- this.$message("开发中...");
- return false;
- case "defaultQRCode":
- this.qrcodeUrl = this.tableData[row.row][val];
- if (this.qrcodeUrl) {
- this.myDialog.qrcode = true;
- } else {
- this.$message("此设备没有设备二维码");
- }
- return false;
-
- case "checked":
- return false;
-
- case "linkSystem":
- if (!this.onlyRead) {
- this.systemList = this.tableData[row.row].linkSystem || [];
- this.myDialog.systemType = true;
- }
- return false;
-
- case "linkEquipLocalName":
- if (this.linkNameFalg) {
- this.myDialog.changeRea = true;
- }
- return false;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- case "infos.insuranceFile":
- case "infos.archive":
- case "infos.checkReport":
- case "infos.maintainManual":
- case "infos.approachingAcceptance":
- case "infos.acceptanceReport":
- case "infos.operationManual":
- case "infos.originalCertificate":
- case "infos.testReport":
- case "infos.productCertification":
- case "infos.installInstruction":
- case "infos.supplierContract":
- case "infos.drawing":
- case "infos.installDrawing":
- case "infos.designIDGraph":
- case "infos.fanCharacterCurve":
- let IPSdata = tools.dataForKey(this.tableData[row.row], val);
- this.filesArr = IPSdata ? IPSdata : [];
- this.myDialog.uploadFiles = true;
- return false;
-
- case "infos.installPic":
- case "infos.nameplate":
- let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
- this.imgsArr = SSPPdata ? SSPPdata : [];
- this.myDialog.uploadImgs = true;
- return false;
-
- case "infos.pic":
- let Pdata = tools.dataForKey(this.tableData[row.row], val);
- this.picsArr = Pdata ? Pdata : [];
- this.myDialog.pic = true;
- return false;
-
- 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 },
- });
- }
- return false;
- default:
- break;
- }
-
- if (!this.onlyRead && inputData.dataType == "MENUM") {
- this.updateInfoData = inputData;
- this.updateInfoPoint = val;
- this.updateInput = tools.dataForKey(this.tableData[row.row], val);
- this.myDialog.menum = true;
- return false;
- }
-
- if (!this.onlyRead && (inputData.region || inputData.multiple)) {
- this.$confirm("该信息点为区间值/复数值,暂无组件支持输入!", "提示", {
- confirmButtonText: "我知道了",
- showCancelButton: false,
- type: "warning",
- center: true,
- }).then(() => {
- return false;
- });
- }
- if (!this.onlyRead && !inputData.editable) {
- this.$confirm("该信息点的值为自动生成,不可人工维护!", "提示", {
- confirmButtonText: "我知道了",
- showCancelButton: false,
- type: "warning",
- center: true,
- }).then(() => {
- return false;
- });
- }
- },
- utilToKey(key, name, data, messName) {
- if (key == name) {
- this.setDataToMain(data[key], messName, this.row);
- }
- },
-
- handleChangeMenum(newValue) {
- tools.setDataForKey(
- this.tableData[this.row],
- this.updateInfoPoint,
- newValue
- );
- this.handleUpdataTable(
- [[this.row, this.updateInfoPoint, null, newValue]],
- "edit"
- );
- this.myDialog.menum = false;
- this.updateInput = "";
- },
-
- 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>
|