123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862 |
- <!--
- 上传文件的弹窗
- -->
- <template>
- <div>
- <el-dialog
- :title="title"
- :center="isCenter"
- :visible.sync="dialog.addDevice"
- :width="width"
- :fullscreen="isFull"
- :before-close="close"
- >
- <div id="addDevice">
- <div v-show="!isCenter">
- <my-cascader ref="cascader" @change="changeCader"></my-cascader>
- </div>
- <div v-if="isCenter">
- <div>
- <div class="hanson-bar">
- <span>当前选择的设备族:{{deviceType.facility}}</span>
- <div style="width:500px;float:right;overflow:hidden;">
- <span>增加</span>
- <el-input v-model="addNum" style="width:40px;" placeholder="增加个数" size="small"></el-input>
- <span>个{{deviceType.facility}}</span>
- <el-button size="small" @click="addMain">增加</el-button>
- <el-button size="small" @click="undo" icon="iconfont icon-undo">撤销</el-button>
- </div>
- </div>
- <div v-show="main && main.length" id="myHandson" ref="myHandson"></div>
- </div>
- </div>
- </div>
- <div v-show="!isCenter" slot="footer" class="dialog-footer">
- <el-button>取 消</el-button>
- <el-button type="primary" @click="step(1)">下 一 步</el-button>
- </div>
- <span v-show="isCenter" slot="footer" class="dialog-footer">
- <el-button type="primary" @click="createAssets">创建系统</el-button>
- </span>
- </el-dialog>
- <qrcode :dialog="myDialog" :addBody="true" ref="qrcode"></qrcode>
- <firm ref="firm" :dialog="myDialog"></firm>
- <supply-dialog @change="supplyChange" :id="id" ref="supply" :dialog="myDialog"></supply-dialog>
- <supplier-dialog ref="supplier" @changeSupplier="supplierChange" :dialog="myDialog"></supplier-dialog>
- <guarantee-dialog ref="guarantee" :id="id" @change="guaranteeChange" :dialog="myDialog"></guarantee-dialog>
- <upload-files-dialog
- ref="upload"
- @changeFile="fileChange"
- :keysArr="filesArr"
- :dialog="myDialog"
- ></upload-files-dialog>
- <upload-img-dialog @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 :dialog="myDialog" :keysArr="picsArr" @change="changePics"></pic-dialog>
- </div>
- </template>
- <script>
- import myCascader from "@/components/lib/cascaders/system";
- import hansonTable from "@/components/dialogHanson/addDevice";
- import tools from "@/assets/js/tools";
- import qrcode from "@/components/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 "@/assets/js/chosen.jquery.min";
- import "@/assets/js/handsontable-chosen-editor";
- import { getTableHeader, BatchCreateSome, getSpaceFloor } from "@/api/request";
- let table = function (num) {
- let main = []
- for (let i = 0; i < num; i++) {
- main.push({})
- }
- return main
- }
- export default {
- components: {
- myCascader,
- hansonTable,
- qrcode, //二维码页面
- firm, //
- supplyDialog,
- supplierDialog,
- guaranteeDialog,
- uploadFilesDialog,
- maintainerDialog,
- insurerDialog,
- uploadImgDialog,
- picDialog
- },
- props: {
- dialog: {
- type: Object,
- default: function () {
- return {
- addDevice: false
- };
- }
- },
- assetType: {
- type: Array,
- default: function () {
- return []
- }
- }
- },
- data() {
- return {
- width: "30%",
- isFull: false,//dialog是否为全屏
- title: "确定新增系统的类型",
- isCenter: false,
- deviceType: {},
- main: table(1),
- mess: {},
- headers: null,
- page: {
- size: 10,
- sizes: [10, 30, 50, 100, 150, 200],
- total: 400,
- currentPage: 1
- },
- id: 0,
- myDialog: {
- qrcode: false, //二维码弹窗
- firm: false, //厂商弹窗
- supply: false, //选择供应合同
- supplier: false, //供应商选择
- guarantee: false, //选择保单
- maintainer: false, //选择维修商
- insurer: false, //选择保险公司
- uploadFiles: false,//上传文件
- uploadImgs: false,//上传单个图片
- pic: false, //多个图片
- },
- addNum: 1,//增加个数
- row: null,//被修改的row
- filesArr: [],//保存临时的文件key
- messKey: null,
- imgsArr: [],//临时保存的图片key数组
- picsArr: [],//临时设备图片keys数组
- param: {
- ProjId: this.$route.query.projId,
- secret: this.$route.query.secret
- },
- floorData: []
- };
- },
- created() {
- this.setValue()
- this.getFloorData()
- },
- mounted() { },
- methods: {
- //设置默认选中数据
- setValue() {
- this.$nextTick(_ => {
- this.$refs.cascader.setValue(this.assetType)
- })
- },
- //关闭
- close(done) {
- this.$emit("close")
- done()
- },
- //获取楼层数据
- getFloorData() {
- getSpaceFloor(this.param).then(res => {
- if (res.data.Result == 'success') {
- let data = this.changeArr(res.data.Content), floorData = []
- data.map(item => {
- floorData.push({
- Code: item.value,
- Name: item.label
- })
- })
- this.floorData = floorData
- } else {
- this.$message.error(res.data.ResultMsg)
- }
- }).catch(() => {
- this.$message.error("请求出错")
- })
- },
- //将数组转换成optiosn格式
- 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,
- }
- }
- })
- },
- //增加个数
- addMain() {
- for (let i = 0; i < this.addNum; i++) {
- this.main.push({})
- }
- this.hot.loadData(this.main)
- },
- //下一步
- step(val) {
- if (!!val) {
- this.isFull = true
- this.isCenter = true
- this.title = "添加系统"
- this.getData()
- } else {
- this.isFull = false
- this.isCenter = false
- }
- },
- //修改设备类型
- changeCader(val) {
- this.deviceType = val
- },
- //获取header的mess
- getHeader(mess) {
- this.mess = mess;
- },
- //获取主体内容
- getMain(floorMess) {
- },
- //获取表头
- getData() {
- this.main = table(1)
- getTableHeader({
- code: this.deviceType.code,
- ProjId: this.$route.query.projId
- }).then(res => {
- this.headers = res.data.Content;
- if (!!this.hot) {
- this.hot.destroy();
- this.hot = null;
- }
- let data = tools.getItem(this.deviceType.code)
- if (!!data) {
- this.main = data
- }
- this.initHot();
- });
- },
- //撤回
- undo() {
- this.hot.undo();
- },
- //刷新
- reset() {
- this.getData();
- },
- //创建资产
- createAssets() {
- let data = []
- let copyData = tools.copyArr(this.main)
- copyData.map(item => {
- if (!!item.infos || !!item.relation) {
- item.equipment_category = this.deviceType.code
- data.push(item)
- }
- })
- data = data.map(item => {
- if (!!item.infos) {
- for (let key in item.infos) {
- item.infos[key] = [{ "value": item.infos[key] != "" ? item.infos[key] : null }]
- }
- }
- if (!!item.flowBuild) {
- if (!!item.building_id) {
- } else {
- item.building_id = ""
- }
- item.building_id = item.flowBuild
- delete item.flowBuild
- }
- return item
- })
- if (data.length) {
- this.createJson(data)
- } else {
- this.$message.error("信息点不能为空")
- }
- },
- //新建资产请求
- async createJson(data) {
- let param = {
- data: { criterias: data },
- ProjId: this.$route.query.projId,
- secret: this.$route.query.secret
- }
- console.log(param)
- this.createPost(param)
- },
- async createPost(param) {
- BatchCreateSome(param, res => {
- // console.log("change")
- this.$emit("close", this.deviceType)
- tools.removeItem(this.deviceType.code)
- this.dialog.addDevice = false
- this.$message.success("创建成功")
- })
- },
- /**
- * 表头文案处理函数
- * @param arr header数组数据
- *
- * @return 处理好的文案
- */
- delHeader(arr) {
- let data = arr.map(item => {
- if (
- item.InputMode == "A1" ||
- item.InputMode == "A2" ||
- item.InputMode == "B1" ||
- item.InputMode == "C5" ||
- item.InputMode == "D1" ||
- item.InputMode == "D2" ||
- item.InputMode == "X" ||
- item.InputMode == "L" ||
- item.InputMode == "L1" ||
- item.InputMode == "L2" ||
- item.InputMode == "F1" ||
- item.InputMode == "F2"
- ) {
- if (item.Unit == "") {
- return item.InfoPointName;
- } else {
- return item.InfoPointName + "(" + item.Unit + ")";
- }
- } else {
- return undefined;
- }
- });
- data = data.filter(item => item);
- data.unshift("所属建筑楼层");
- return data;
- },
- /**
- * 表头数据处理函数
- * @param arr header数组数据
- *
- * @return 处理好的数据格式
- */
- getType(arr) {
- let data = arr.map(item => {
- //二维码
- if (item.InfoPointCode == "EquipQRCode") {
- return {
- data: "infos." + item.InfoPointCode,
- renderer: tools.lookDetails,
- readOnly: true
- }
- }
- //厂商选择
- if (item.InfoPointCode == "Brand" || item.InfoPointCode == "Specification") {
- return {
- data: "infos." + item.InfoPointCode,
- renderer: tools.lookDetails,
- readOnly: true
- }
- }
- if (item.InfoPointCode == "SupplierContractID") {
- return {
- data: "infos." + item.InfoPointCode,
- renderer: tools.lookDetails,
- readOnly: true
- }
- }
- if (item.InfoPointCode == "InsuranceNum") {
- //选择保单
- return {
- data: "infos." + item.InfoPointCode,
- renderer: tools.lookDetails,
- readOnly: true
- }
- }
- if (item.InfoPointCode == "InsuranceFile" || item.InfoPointCode == "Archive") {
- return {
- data: "infos." + item.InfoPointCode,
- renderer: tools.lookDetails,
- readOnly: true
- }
- }
- if (
- item.InfoPointCode == "InstallLocation" ||
- item.InfoPointCode == "InstallPic" ||
- item.InfoPointCode == "InstallDrawing" ||
- item.InfoPointCode == "Nameplate" ||
- item.InfoPointCode == "Pic" ||
- item.InfoPointCode == "Drawing"
- ) {
- return {
- data: "infos." + item.InfoPointCode,
- renderer: tools.lookDetails,
- readOnly: true
- }
- }
- if (
- item.InfoPointCode == "Maintainer" ||
- item.InfoPointCode == "Supplier" ||
- item.InfoPointCode == "Insurer" ||
- item.InfoPointCode == "InsurerContactor"
- ) {
- return {
- data: "infos." + item.InfoPointCode,
- renderer: tools.lookDetails,
- readOnly: true
- }
- }
- if (item.InputMode == "D1") {
- return {
- data: "infos." + item.InfoPointCode,
- renderer: tools.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- // multiple: true,//多选
- data: item.DataSource.Content || ""
- }
- };
- } else if (item.InputMode == "A1" || item.InputMode == "A2") {
- return {
- data: "infos." + item.InfoPointCode,
- type: "numeric",
- numericFormat: {
- pattern: "0,0.00"
- // culture: 'de-DE' // use this for EUR (German),
- // more cultures available on http://numbrojs.com/languages.html
- }
- };
- } else if (item.InputMode == "C5") {
- return {
- data: "infos." + item.InfoPointCode,
- type: "date",
- dateFormat: "YYYY-MM-DD",
- correctFormat: true
- };
- } else if (
- item.InputMode == "B1" ||
- item.InputMode == "L" ||
- item.InputMode == "L1" ||
- item.InputMode == "L2"
- ) {
- return {
- data: "infos." + item.InfoPointCode
- };
- } else if (
- item.InputMode == "X" ||
- item.InputMode == "F2"
- // item.InputMode == "L1" ||
- // item.InputMode == "L2"
- ) {
- return {
- data: "infos." + item.InfoPointCode,
- readOnly: true
- };
- } else if (item.InputMode == "D2") {
- return {
- data: "infos." + item.InfoPointCode,
- renderer: tools.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- multiple: true, //多选
- data: item.DataSource.Content || ""
- }
- };
- } else {
- return undefined;
- }
- });
- data.unshift(
- {
- data: "flowBuild",
- renderer: tools.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- // multiple: true,//多选
- data: this.floorData
- }
- }
- );
- data = data.filter(item => item);
- return data;
- },
- //初始化插件
- initHot() {
- var container = document.getElementById("myHandson");
- let winHeight = document.documentElement.clientHeight;
- this.hot = new Handsontable(container, {
- data: this.main,
- colHeaders: this.delHeader(this.headers), //表头文案
- columns: this.getType(this.headers), //数据显示格式
- filters: true,
- height: winHeight - 100 - 50 - 60,
- columnSorting: true, //添加排序
- sortIndicator: true, //添加排序
- renderAllRows: true,
- autoColumnSize: true,
- language: "zh-CN",
- manualColumnResize: true,
- manualColumnMove: true,
- dropdownMenu: [
- "filter_by_condition",
- "filter_by_value",
- "filter_action_bar"
- ],
- contextMenu: {
- items: {
- remove_row: {
- name: "删除该资产"
- }
- }
- },
- afterChange: this.tdChange, //修改后
- afterFilter: this.trimmedRows, //排序前
- afterRemoveRow: this.romoveFm, //右键删除
- afterOnCellMouseDown: this.eventClick //鼠标点击
- });
- let pro = document.getElementById("hot-display-license-info");
- if (!!pro) {
- pro.parentNode.removeChild(pro);
- }
- this.isLoading = false;
- },
- tdChange() {
- tools.setItem(this.deviceType.code, this.main)
- },
- //表格中的点击
- eventClick(el, rowArr) {
- //点击的是表头
- if (rowArr.row < 0) {
- return;
- }
- let filter = this.filtersArr;
- //被筛选过后的数组
- let trimmedArr = this.trimmedRows();
- //是否启用了排序
- let isSort = this.hot.getPlugin("columnSorting").isSorted();
- if (trimmedArr.length && isSort) {
- let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
- .__arrayMap;
- let infos = this.main[trimmedArr[sortArr[rowArr.row]]];
- this.getInfors(infos, sortArr[rowArr.row]);
- } else if (isSort) {
- //排序后的数组
- let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
- let infos = this.main[sortArr[rowArr.row]];
- this.getInfors(infos, sortArr[rowArr.row]);
- } else if (trimmedArr.length) {
- let infos = this.main[trimmedArr[rowArr.row]];
- this.getInfors(infos, trimmedArr[rowArr.row]);
- } else {
- let infos = this.main[rowArr.row];
- this.getInfors(infos, rowArr);
- }
- },
- getInfors(infos, row) {
- //其他的开始判断
- let val = this.hot.colToProp(row.col);
- if (val == "infos.EquipQRCode") {
- this.myDialog.qrcode = true;
- this.$refs.qrcode.getCanvas(1111);
- }
- if (val == "infos.Brand" || val == "infos.Specification") {
- this.myDialog.firm = true;
- }
- if (val == "infos.SupplierContractID") {
- let falg = null
- if (!!this.main[row.row].infos) {
- if (!!this.main[row.row].infos) {
- falg = this.main[row.row].infos.DPSupplierID
- }
- }
- if (!!falg) {
- this.id = falg
- this.myDialog.supply = true;
- } else {
- this.$message("请先选择供应商")
- }
- }
- if (val == "infos.InsuranceNum") {
- //选择保单
- let falg = null
- if (!!this.main[row.row].infos) {
- if (!!this.main[row.row].infos) {
- falg = this.main[row.row].infos.DPInsurerID
- }
- }
- if (!!falg) {
- this.id = falg
- this.myDialog.guarantee = true;
- } else {
- this.$message("请先选择保险商")
- }
- }
- if (val == "infos.InsuranceFile" || val == "infos.Archive") {
- this.filesArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
- this.myDialog.uploadFiles = true
- }
- if (
- val == "infos.InstallLocation" ||
- val == "infos.InstallPic" ||
- val == "infos.InstallDrawing" ||
- val == "infos.Nameplate" ||
- val == "infos.Drawing"
- ) {
- if (val == "infos.Nameplate") {
- this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]].key] : []) : []
- } else {
- this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
- }
- this.myDialog.uploadImgs = true
- }
- if (val == "infos.Pic") {
- // console.log(this.main[row.row].infos[val.split(".")[1]], "this.main[row.row].infos[val.split")
- this.picsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
- console.log(this.picsArr)
- this.myDialog.pic = true
- }
- if (
- val == "infos.Supplier"
- ) {
- this.myDialog.supplier = true;
- }
- if (val == "infos.Maintainer") {
- this.myDialog.maintainer = true;
- }
- if (
- val == "infos.Insurer" ||
- val == "infos.InsurerContactor") {
- this.myDialog.insurer = true;
- }
- this.row = row.row
- this.messKey = val
- console.log(val, row);
- },
- //获取被筛选掉的行号
- trimmedRows() {
- // var plugin = hot.getPlugin('trimRows').trimmedRows;//获取被筛选掉的行号
- var plugin = this.hot.getPlugin("trimRows").trimmedRows;
- let dataLength = this.main.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 || [];
- // var DataArray = new Array();
- // for (var i = 0; i < plugin.length; i++) {
- // // 通过行号获取数据
- // DataArray.push(this.hot.getSourceDataAtRow(plugin[i]));
- // }
- },
- //判断是否为空行
- isEmptyRow(instance, row) {
- var rowData = instance.countRows();
- for (var i = 0, ilen = rowData.length; i < ilen; i++) {
- if (rowData[i] !== null) {
- return false;
- }
- }
- return true;
- },
- //如果选择供应商之后
- supplierChange(data) {
- console.log(data, "供应商")
- for (let key in data) {
- this.utilToKey(key, "name", data, "Supplier")
- this.utilToKey(key, "email", data, "SupplierEmail")
- this.utilToKey(key, "website", data, "SupplierWeb")
- this.utilToKey(key, "phone", data, "SupplierPhone")
- this.utilToKey(key, "fox", data, "SupplierFax")
- this.utilToKey(key, "man", data, "SupplierContactor")
- this.utilToKey(key, "venderId", data, "DPSupplierID")
- }
- tools.setItem(this.deviceType.code, this.main)
- },
- //供应商合同
- supplyChange(data) {
- let changeData = { id: data }
- this.utilToKey("id", "id", changeData, "SupplierContractID")
- tools.setItem(this.deviceType.code, this.main)
- },
- //保险合同
- guaranteeChange(data) {
- console.log("保险合同发生改变", data)
- for (let key in data) {
- this.utilToKey(key, "insuranceNo", data, "InsuranceNum")
- this.utilToKey(key, "contractFile", data, "InsuranceFile")
- }
- tools.setItem(this.deviceType.code, this.main)
- },
- //保险商变更
- changeInsurer(data) {
- console.log(data, "保险商")
- for (let key in data) {
- this.utilToKey(key, "name", data, "Insurer")
- this.utilToKey(key, "email", data, "InsurerEmail")
- this.utilToKey(key, "website", data, "InsurerWeb")
- this.utilToKey(key, "phone", data, "InsurerFax")
- this.utilToKey(key, "man", data, "InsurerContactor")
- this.utilToKey(key, "venderId", data, "DPInsurerID")
- }
- tools.setItem(this.deviceType.code, this.main)
- },
- //维修商变更
- changeMaintainer(data) {
- for (let key in data) {
- this.utilToKey(key, "name", data, "Maintainer")
- this.utilToKey(key, "email", data, "MaintainerEmail")
- this.utilToKey(key, "website", data, "MaintainerWeb")
- this.utilToKey(key, "phone", data, "MaintainerPhone")
- this.utilToKey(key, "fox", data, "MaintainerFax")
- this.utilToKey(key, "man", data, "MaintainerContactor")
- this.utilToKey(key, "venderId", data, "DPMaintainerID")
- }
- tools.setItem(this.deviceType.code, this.main)
- },
- utilToKey(key, name, data, messName) {
- if (key == name) {
- this.setDataToMain(data[key], messName, this.row)
- }
- },
- //上传文件弹窗触发事件
- fileChange(keys) {
- this.setDataToMain(keys[0], this.messKey.split(".")[1], this.row)
- tools.setItem(this.deviceType.code, this.main)
- },
- //上传图片弹窗触发事件
- imgChange(keys) {
- this.setDataToMain(keys[0], this.messKey.split(".")[1], this.row)
- tools.setItem(this.deviceType.code, this.main)
- },
- //设备图片弹窗改变事件
- changePics(keys) {
- this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
- tools.setItem(this.deviceType.code, this.main)
- console.log("assets", keys)
- },
- //判断是否有值,有值赋值
- setDataToMain(data, key, row) {
- if (!!data && data != '--') {
- if (!!this.main[row].infos) {
- //铭牌照片特殊处理
- if (key == 'Nameplate') {
- this.main[row].infos[key] = {
- "systemId": "dataPlatform",
- "name": "铭牌照片",
- "type": "image",
- "key": data
- }
- } else {
- this.main[row].infos[key] = data
- }
- } else {
- this.main[row].infos = {}
- if (key == 'Nameplate') {
- this.main[row].infos[key] = {
- "systemId": "dataPlatform",
- "name": "铭牌照片",
- "type": "image",
- "key": data
- }
- } else {
- this.main[row].infos[key] = data
- }
- }
- } else {
- this.main[row].infos[key] = ''
- }
- }
- },
- watch: {
- dialog: {
- deep: true,
- handler: function () {
- console.log("changed")
- if (this.dialog.addDevice) {
- this.setValue()
- }
- }
- }
- }
- };
- </script>
- <style lang="less" scoped>
- #addDevice {
- overflow: hidden;
- }
- </style>
|