1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054 |
- <template>
- <div style="height: calc(100% - 44.5px);padding: 0px 10px 10px;box-sizing: border-box;">
- <div class="hanson-bar">
- <div style="float:right;overflow:hidden;">
- <!-- <span style="width:20px;float:left;display:block;height:20px;cursor: pointer;" @click="changeAssetsFalg">
- <i v-if="!onlyRead" class="el-icon-fa el-icon-fa-eye"></i>
- </span> -->
- <span>当前筛选条件下共{{page.total || '--'}}设备</span>
- </div>
- <el-select v-model="onlyRead" @change="getHeaderData(mess)" style="width:100px;margin-right:20px;vertical-align:bottom;">
- <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
- </el-select>
- <el-select v-model="showType" @change="initTable" style="width:130px;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>
- <el-button size="small" style="width: 80px;" @click="addDevice" icon="iconfont icon-tianjia">添加资产</el-button>
- <el-button size="small" style="width: 80px;" @click="reset" icon="iconfont icon-shuaxin">刷新</el-button>
- <el-button v-show="!onlyRead" size="small" style="width: 80px;" @click="undo" icon="iconfont icon-undo">撤销</el-button>
- </div>
- <qrcode :qrcodeUrl="qrcodeUrl" :dialog="myDialog" :addBody="true" ref="qrcode"></qrcode>
- <firm ref="firm" :mess="mess" @changeFirm="firmChange" :dialog="myDialog"></firm>
- <supply-dialog @change="supplyChange" ref="supply" :id="id" :dialog="myDialog"></supply-dialog>
- <supplier-dialog ref="supplier" @changeSupplier="supplierChange" :dialog="myDialog"></supplier-dialog>
- <guarantee-dialog @change="guaranteeChange" :id="id" ref="guarantee" :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>
- <div class="center middle_sty" style="height: 91%" v-show="!mess.deviceId && (!tableData || !tableData.length)">
- <p>
- <i class="icon-wushuju iconfont"></i>
- 请选择设备族
- </p>
- </div>
- <div class="center middle_sty" style="height: 91%" v-show="mess.deviceId && (!tableData || !tableData.length)">
- <p>
- <i class="icon-wushuju iconfont"></i>
- 暂无数据
- </p>
- </div>
- <div v-show="mess.deviceId && tableData && tableData.length" v-loading="loading" id="handsontable" ref="handsontable"></div>
- <div v-show="tableData && tableData.length" class='right'>
- <my-pagination @change="getTableData" :page="page"></my-pagination>
- </div>
- <!-- <dialog-assets :assetType="[this.mess.deviceId]" @close="closeDialog" ref="assets" v-if="myDialog.addDevice" :dialog="myDialog" ></dialog-assets> -->
- <!-- <details-dialog :iframeSrc="iframeSrc" v-if="myDialog.details" :dialog="myDialog"></details-dialog> -->
- <look-pic :dialog="myDialog" :keysArr="picsArr"></look-pic>
- <!-- 不支持的输入方式 -->
- <el-dialog title="临时维护信息点" :visible.sync="myDialog.update" @close="handleCloseUpdate" width="670px">
- <el-row>
- 该信息点未定义对应组件,现在维护数据不确定后续是否可用。如确实需要维护,请点击<el-link @click="updateInputShow = true" type="primary" :underline="false">继续维护</el-link>。
- </el-row>
- <el-row style="margin-top:20px;" v-show="updateInputShow">
- <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 8}" placeholder="请输入内容" v-model="updateInput"></el-input>
- </el-row>
- <span slot="footer" class="dialog-footer">
- <el-button @click="myDialog.update = false">取 消</el-button>
- <el-button type="primary" @click="handleClickUpdate">确 认</el-button>
- </span>
- </el-dialog>
- <!-- 新增资产 -->
- <el-dialog class="add-assets" :title="showAddByDie?'未关联资产的设备批量创建资产':'确定新增资产类型'" @close="showAddByDie = false" :visible.sync="myDialog.addDevice"
- width="670px">
- <el-row>
- <my-cascader v-show="!showAddByDie" ref="cascader" :all="true" @change="changeCader"></my-cascader>
- <die-cascader v-show="showAddByDie" ref="dieCascader" :Family="addData.Family" @change="changeDevice"></die-cascader>
- <floor-cascader v-show="showAddByDie" @change="changeFloor"></floor-cascader>
- <div class="die-text" v-show="showAddByDie">当前筛选条件下有<span class="die-num">{{dieNum}}</span>个设备可批量创建资产。</div>
- <el-link v-show="showAddByDie && dieNum" type="primary" :underline="false" @click="toDetaiPage" style="margin-left:10px;">查看详情</el-link>
- </el-row>
- <span slot="footer" class="dialog-footer">
- <el-button v-show="!showAddByDie" type="primary" @click="toAddbyDie">批量创建</el-button>
- <el-button v-show="!showAddByDie" type="primary" @click="toAddDevice">手动添加</el-button>
- <el-button v-show="showAddByDie" type="primary" @click="showAddByDie = false">返回</el-button>
- <el-button v-show="showAddByDie" type="primary" :disabled="dieNum == 0" @click="createByDie">批量创建</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getDataDictionary, queryProperty, propertyLinkEq, updateProperty, deleteProperty, countPartsDie, createPropertys, BeatchQueryParam } from "@/api/scan/request";
- import tools from "@/utils/scan/tools"
- import handsonUtils from "@/utils/scan/hasontableUtils"
- import showTools from "@/utils/handsontable/notShow"
- import text from "@/utils/handsontable/mainText"
- import buildFloor from '@/utils/handsontable/buildFloorData'
- import qrcode from "@/components/business_space/lib/qrcode"
- import firm from "@/components/business_space/dialogs/list/firm"
- import supplyDialog from "@/components/business_space/dialogs/list/supplyDialog"
- import supplierDialog from "@/components/business_space/dialogs/list/supplierDialog"
- import maintainerDialog from "@/components/business_space/dialogs/list/maintainerDialog"
- import insurerDialog from "@/components/business_space/dialogs/list/insurerDialog"
- import guaranteeDialog from "@/components/business_space/dialogs/list/guaranteeDialog"
- import uploadFilesDialog from "@/components/business_space/dialogs/list/filesDialog"
- import uploadImgDialog from "@/components/business_space/dialogs/list/uploadImgDialog"
- // import detailsDialog from "@/components/business_space/lib/detailsDia"
- import picDialog from "@/components/business_space/dialogs/list/picDialog"
- import myPagination from "@/components/common/myPagination"
- import dialogAssets from "@/components/ledger/addDialog/dialogAssets"
- import myCascader from "@/components/ledger/lib/assets"
- import floorCascader from "@/components/ledger/lib/floorCascader"
- import dieCascader from "@/components/ledger/lib/partsDieList"
- import { mapGetters, mapActions } from "vuex"
- //图片查看
- import lookPic from "@/components/ledger/lib/lookImages"
- import Handsontable from "handsontable-pro"
- import 'handsontable-pro/dist/handsontable.full.css'
- import zhCN from 'handsontable-pro/languages/zh-CN'
- //下拉插件
- // import "@/assets/js/chosen.jquery.min";
- // import "@/assets/js/handsontable-chosen-editor";
- export default {
- components: {
- qrcode, //二维码页面
- firm, //
- supplyDialog,
- supplierDialog,
- guaranteeDialog,
- uploadFilesDialog,
- maintainerDialog,
- insurerDialog,
- uploadImgDialog,
- picDialog,
- myPagination,
- // dialogAssets,
- myCascader,
- floorCascader,
- dieCascader,
- // detailsDialog,
- lookPic
- },
- created() {
- buildFloor.getData(this.buildFloorData)
- },
- computed: {
- ...mapGetters("layout", ["projectId", "secret", "userId"]),
- showTypes() {
- return this.onlyRead ?
- [{ value: "Visible", label: '只看采集信息' }, { value: "all", label: '全部' }] :
- [{ value: "partInfo", label: '隐藏信息点' }, { value: "Visible", label: '只看采集信息' }, { value: "all", label: '全部' }]
- }
- },
- data() {
- return {
- options: [{
- value: true,
- label: '只读模式'
- }, {
- value: false,
- label: '编辑模式'
- }],
- buildFloorData: [], //楼层数据
- tableData: [],
- mess: {},
- tableHeader: null,
- page: {
- size: 50,
- sizes: [10, 30, 50, 100, 150, 200],
- total: 0,
- currentPage: 1
- },
- 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,//图片查看
- update: false,//临时维护信息点
- },
- row: null, //被修改的row
- filesArr: [], //保存临时的文件key
- messKey: null,
- imgsArr: [], //临时保存的图片key数组
- picsArr: [], //临时资产图片keys数组
- copyMain: null,
- graphyId: null,
- assetGroupList: [],
- iframeSrc: "",
- id: 0,
- onlyRead: true,
- showType: 'Visible',
- linkNameFalg: false,
- qrcodeUrl: "", //二维码图片地址
- loading: false,
- deviceType: {}, //族3位编码及名称
- floorData: [],
- curDevice: '',//当前点击的资产id
- showAddByDie: false,//是否显示通过设备添加资产页面
- addData: {}, //添加资产选择的资产类型
- numParams: { // 查询设备部件数量条件
- category: '',
- buildId: '',
- floorId: '',
- Family: ''
- },
- dieNum: 0, // 查询设备部件数量
- inputMap: {
- flowBuild: 'D1'
- }, //信息点和输入方式映射表
- updateInputShow: false, //是否显示临时维护输入框
- updateInfoPoint: '',//临时维护信息点
- updateInput: '', //临时维护信息点值
- };
- },
- methods: {
- //获取表头
- getHeaderData(code) {
- this.page.currentPage = 1
- this.mess = code
- if (this.mess.deviceId) {
- let params = {
- data: {
- Orders: "sort asc",
- PageNumber: 1,
- PageSize: 500
- },
- type: this.mess.deviceId
- };
- getDataDictionary(params, res => {
- this.tableHeader = res.Content;
- this.tableHeader.forEach(item => {
- if(item.Path && item.InputMode){
- this.inputMap[item.Path] = item.InputMode
- }
- })
- this.getTableData()
- });
- }
- },
- //获取主体数据
- getTableData() {
- this.loading = true
- //type存在发送请求
- if (!!this.mess.deviceId) {
- let param = {
- PageSize: this.page.size,
- Orders: "createTime desc, EquipID desc",
- PageNumber: this.page.currentPage,
- Filters: `Family='${this.mess.deviceId}'`
- }
- if (this.mess.buildId == "noKnow") {
- param.Filters += `;buildingId isNull`
- } else if (this.mess.buildId && this.mess.buildId != "all") {
- param.Filters += `;buildingId='${this.mess.buildId}'`
- }
- if (this.mess.floorId == "noKnow") {
- param.Filters += `;floorId isNull`
- } else if (this.mess.floorId && this.mess.floorId != "all") {
- param.Filters += `;floorId='${this.mess.floorId}'`
- }
- propertyLinkEq(param, res => {
- this.loading = false
- this.tableData = res.Content.map((item) => {
- if (item.hasOwnProperty("BuildingId") && item.hasOwnProperty("FloorId")) {
- item.flowBuild = item.BuildingId + "-" + item.FloorId
- } else if (item.hasOwnProperty("BuildingId") && !item.hasOwnProperty("FloorId")) {
- item.flowBuild = item.BuildingId
- }
- return item
- })
- this.copyMain = tools.deepCopy(this.tableData)
- this.page.total = res.Total
- if (this.tableData && this.tableData.length) {
- // if (this.onlyRead) {
- // this.getBatch(this.tableData)
- // }
- this.initTable()
- }
- })
- }
- },
- //获取动态参数
- getBatch(data) {
- let param = {
- secret: this.secret,
- ProjId: this.projectId,
- data: {
- criterias: []
- }
- };
- this.tableHeader.map(head => {
- if (
- head.InputMode == "L" ||
- head.InputMode == "L1" ||
- head.InputMode == "L2" ||
- head.InputMode == "M"
- ) {
- data.map(item => {
- let cur = tools.dataForKey(item, head.Path);
- if (cur) {
- param.data.criterias.push({
- id: item.EquipID,
- code: head.InfoPointCode
- });
- }
- });
- }
- });
- if (param.data.criterias.length) {
- BeatchQueryParam(param, res => {
- this.tableData = data.map(item => {
- res.Content.map(child => {
- if (item.EquipID == child.id) {
- if (child.data || child.data == 0) {
- this.tableHeader.map(head => {
- if (head.InfoPointCode == child.code) {
- tools.setDataForKey(item, head.Path, child.data);
- }
- });
- } else {
- this.tableHeader.map(head => {
- if (head.InfoPointCode == child.code) {
- tools.setDataForKey(
- item,
- head.Path,
- // child.error ? "表号功能号格式错误" : "表号功能号不存在"
- child.error ? child.value? "表号功能号格式错误" : "表号功能号不存在" : "暂未采集到实时数据"
- );
- }
- });
- }
- }
- });
- return item;
- });
- this.hot.loadData(this.tableData);
- });
- }
- },
- //撤回
- undo() {
- this.hot.undo();
- },
- //刷新-switch改变
- reset() {
- this.getTableData();
- },
- //添加资产
- addDevice() {
- this.myDialog.addDevice = true
- if (this.mess.deviceId) {
- this.$nextTick(() => {
- this.$refs.cascader.setValue(this.mess.deviceId)
- this.addData.Family = this.mess.deviceId
- this.numParams.Family = this.mess.deviceId
- })
- }
- },
- //手动创建
- toAddDevice() {
- if (this.addData.Family) {
- this.$router.push({
- path: "/ledger/propertyadd",
- query: this.addData
- });
- } else {
- this.$message("请选择设备族")
- }
- },
- //显示通过部件或设备创建资产页
- toAddbyDie() {
- if (this.addData.Family) {
- this.showAddByDie = true
- this.$nextTick(() => {
- this.$refs.dieCascader.getAllData()
- })
- } else {
- this.$message("请选择设备族")
- }
- },
- //格式化条件
- formatFilter() {
- let param = {
- Filters: `category='${this.numParams.category}';PropertyId isNull`
- }
- if (this.numParams.buildId == "noKnow") {
- param.Filters += `;buildingId isNull`
- } else if (this.numParams.buildId && this.numParams.buildId != "all") {
- param.Filters += `;buildingId='${this.numParams.buildId}'`
- }
- if (this.numParams.floorId == "noKnow") {
- param.Filters += `;floorId isNull`
- } else if (this.numParams.floorId && this.numParams.floorId != "all") {
- param.Filters += `;floorId='${this.numParams.floorId}'`
- }
- return param
- },
- //批量添加
- createByDie() {
- let param = this.formatFilter()
- createPropertys(param, res => {
- this.myDialog.addDevice = false
- this.$emit('getJson', { code: this.numParams.Family })
- this.$message.success("创建成功!")
- })
- },
- //获取未关联资产的设备或部件数量
- getNumDie() {
- let param = this.formatFilter()
- countPartsDie(param, res => {
- this.dieNum = res.Count
- })
- },
- //查看详情
- toDetaiPage() {
- this.$router.push({
- path: "/ledger/addPropertys",
- query: this.numParams
- })
- },
- //选择设备类型-添加资产
- changeCader(val) {
- if (val.code && val.facility) {
- this.addData.Family = val.code
- this.addData.name = val.facility
- this.numParams.Family = val.code
- }
- },
- //选择设备或部件
- changeDevice(val) {
- if (val.code) {
- this.numParams.category = val.code
- } else {
- this.numParams.category = ''
- }
- this.getNumDie()
- },
- //选择建筑楼层
- changeFloor(value) {
- if (value[0]) {
- this.numParams.buildId = value[0]
- }
- if (value[1]) {
- this.numParams.floorId = value[1]
- } else {
- this.numParams.floorId = ''
- }
- this.getNumDie()
- },
- //下载
- download() {
- if (!this.onlyRead) {
- if (!!this.hot) {
- let fileName = this.mess.name + "-页数:" + this.page.currentPage + "-个数:" + this.tableData.length + "-总个数:" + this.page.total
- this.hot.getPlugin('exportFile').downloadFile("csv", { filename: fileName, columnHeaders: true, exportHiddenRows: true, exportHiddenColumns: true, rowHeaders: true })
- } else {
- this.$message("请确定存在表格")
- }
- } else {
- this.$message("下载需在编辑状态下")
- }
- },
- //格式化表头
- formatHeaderData(list) {
- let arr = tools.copyArr(list)
- let data = showTools.headerTextFilter(arr, 'property', this.onlyRead, this.showType, true)
- data.unshift("操作", "当前关联的设备")
- if (this.showType == "all") {
- data.splice(4, 0, "所属建筑楼层")
- }
- return data
- },
- //格式化表内容
- formatHeaderType(list) {
- let arr = tools.copyArr(list)
- let data = showTools.headerTypeFilter(arr, 'property', this.onlyRead, this.showType, true)
- data.unshift(
- {
- data: "caozuo",
- renderer: tools.lookDetails
- }, {
- data: "LinkEquipLocalName",
- renderer: tools.LinkEquipLocalName,
- readOnly: true
- }
- )
- if (this.showType == "all") {
- data.splice(4, 0, {
- data: "flowBuild",
- renderer: tools.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- data: this.buildFloorData
- },
- readOnly: this.onlyRead
- })
- }
- return data
- },
- //初始化插件
- initTable() {
- var container = document.getElementById("handsontable");
- let winHeight = document.documentElement.clientHeight;
- if (this.hot) {
- this.hot.destroy();
- this.hot = null;
- }
- this.hot = new Handsontable(container, {
- data: this.tableData,
- fixedColumnsLeft: 4,
- colHeaders: this.formatHeaderData(this.tableHeader), //表头文案
- columns: this.formatHeaderType(this.tableHeader), //数据显示格式
- filters: true,
- maxRows: this.tableData.length,
- height: winHeight - 335,
- columnSorting: true, //添加排序
- sortIndicator: true, //添加排序
- renderAllRows: true,
- // observeChanges: false, //启用observeChanges插件
- // colWidths: 200,
- 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.handleUpdataTable, //修改后
- afterFilter: this.trimmedRows, //排序前
- afterRemoveRow: this.handleDeleteTableRow, //右键删除
- afterOnCellMouseDown: this.eventClick //鼠标点击
- });
- let pro = document.getElementById("hot-display-license-info");
- if (!!pro) {
- pro.parentNode.removeChild(pro);
- }
- this.isLoading = false;
- },
- //表格中的点击
- eventClick(el, rowArr) {
- //点击的是表头
- if (rowArr.row < 0) {
- return;
- }
- //被筛选过后的数组
- 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.tableData[trimmedArr[sortArr[rowArr.row]]];
- this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col }, el);
- } else if (isSort) {
- //排序后的数组
- let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
- let infos = this.tableData[sortArr[rowArr.row]];
- this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col }, el);
- } else if (trimmedArr.length) {
- let infos = this.tableData[trimmedArr[rowArr.row]];
- this.getInfors(infos, { row: trimmedArr[rowArr.row], col: rowArr.col }, el);
- } else {
- let infos = this.tableData[rowArr.row];
- this.getInfors(infos, rowArr, el);
- }
- },
- // 更新
- handleUpdataTable(changeData, source) {
- if (!this.onlyRead && source != 'ObserveChanges.change') {
- if (changeData) {
- let trimmedArr = this.trimmedRows();
- let param = handsonUtils.getParam(changeData, source, this.hot, trimmedArr);
- let data = [];
- for (let i = 0; i < param.length; i++) {
- data.push(param[i]);
- }
- //如果data中包含/且data长度为1,将其转换成.
- if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
- changeData[0][1] = changeData[0][1].split("/").join(".")
- }
- //存在data进行修改请求
- if (data && data.length) {
- this.updateProperty(data, changeData);
- }
- }
- }
- },
- //删除资产
- handleDeleteTableRow() {
- let params = tools.differenceArr(this.tableData, this.copyMain)
- let _this = this
- if (params.length < 1) {
- return
- }
- let param = []
- params.map(item => {
- param.push({ EquipID: item.EquipID })
- })
- this.$confirm("此操作将删除资产,是否继续?", "提示", {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.removeDevice(param)
- }).catch(() => {
- this.reset()
- this.$message("取消删除")
- })
- },
- // 删除资产
- async removeDevice(param) {
- await deleteProperty(param, res => {
- this.$message.success("删除成功")
- this.$emit('getJson', '')
- this.getTableData()
- })
- },
- // 更新
- updateProperty(data, change) {
- let param = {
- Content: [],
- Projection: []
- }, keyList = []
- //生成要修改字段列表
- change.map(item => {
- let key = item[1].split(".")[0]
- if (key == "flowBuild" && keyList.indexOf(key) == -1) {
- keyList.push("BuildingId", "FloorId")
- param.Projection.push("BuildingId", "FloorId")
- }
- if (item[1] && keyList.indexOf(key) == -1) {
- keyList.push(key)
- }
- if (item[1] && item[3] == "" && param.Projection.indexOf(key) == -1) {
- param.Projection.push(key)
- }
- })
- //生成对应修改数据
- data.map((item, index) => {
- keyList.map(value => {
- if (value == "BuildingId") {
- let itemData = tools.dataForKey(item, "flowBuild")
- if (itemData == "") {
- tools.setDataForKey(item, "BuildingId", null)
- tools.setDataForKey(item, "FloorId", null)
- } else {
- let BuildingId = itemData.split("-")[0]
- let FloorId = itemData.split("-")[1]
- if (BuildingId && FloorId) {
- tools.setDataForKey(item, "BuildingId", BuildingId)
- tools.setDataForKey(item, "FloorId", FloorId)
- } else if (BuildingId && !FloorId) {
- tools.setDataForKey(item, "BuildingId", BuildingId)
- tools.setDataForKey(item, "FloorId", null)
- }
- }
- } else {
- let itemData = tools.dataForKey(item, value)
- tools.setDataForKey(item, value, itemData == "" ? null : itemData)
- }
- });
- param.Content.push(item)
- })
- updateProperty(param, res => { })
- },
- //修改资产类型
- // changeCader() {
- // if (this.mess.deviceId) {
- // let param = {
- // data: {
- // Filters: `EquipCode='${this.mess.deviceId}'`,
- // PageNumber: 1,
- // PageSize: 50
- // }
- // }
- // getEquipBelongs(param, res => {
- // if (res.Content.length) {
- // this.deviceType.assetType = res.Content[0].Family
- // this.deviceType.assetName = res.Content[0].FamilyName
- // }
- // })
- // }
- // },
- //获取到了正确的信息
- getInfors(infos, row, el) {
- let val = this.hot.colToProp(row.col);
- let inputMode = this.inputMap[val];
- this.row = row.row;
- this.messKey = val;
- switch (val) {
- //操作
- case 'caozuo':
- // window.open(`http://adm.sagacloud.cn:8058/spread?id=${infos.EquipID}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
- this.$message("开发中...")
- return false
- //资产二维码图片
- case 'EquipQRCode':
- this.qrcodeUrl = this.tableData[row.row].EquipQRCode;
- if (!!this.qrcodeUrl) {
- this.myDialog.qrcode = true;
- } else {
- this.$message("此资产没有资产二维码");
- }
- return false
- //关联系统
- case 'LinkSystem':
- if (!this.onlyRead) {
- this.curDevice = infos.EquipID;
- 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 'DPManufacturerID':
- if (!this.onlyRead) {
- this.myDialog.firm = true;
- }
- return false
- //供应商信息弹窗
- case 'DPSupplierID':
- if (!this.onlyRead) {
- this.myDialog.supplier = true;
- }
- return false
- //维修商信息弹窗
- case 'DPMaintainerID':
- if (!this.onlyRead) {
- this.myDialog.maintainer = true;
- }
- return false
- //保险公司信息
- case 'DPInsurerID':
- if (!this.onlyRead) {
- this.myDialog.insurer = true;
- }
- return false
- //供应合同编号
- 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("请先选择供应商");
- }
- }
- return false
- //保险单号
- 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("请先选择保险商");
- }
- }
- return false
- //保险文件--资产文档--安装质检报告
- 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;
- return false
- //安装照片--安装图纸--资产铭牌照片--资产图纸
- 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;
- return false
- //资产照片
- case 'LedgerParam.PhotoDoc.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 && showTools.InputModeArr.indexOf(inputMode) == '-1') {
- this.updateInfoPoint = val
- this.updateInput = tools.dataForKey(this.tableData[row.row], val)
- this.myDialog.update = true
- }
- },
- //关闭临时维护弹窗回调
- handleCloseUpdate() {
- this.updateInputShow = false
- this.updateInfoPoint = ''
- this.updateInput = ''
- },
- //更新临时维护信息点
- handleClickUpdate(){
- tools.setDataForKey(this.tableData[this.row], this.updateInfoPoint, this.updateInput)
- this.handleUpdataTable([[this.row, this.updateInfoPoint, null, this.updateInput]], "edit")
- this.updateInputShow = false
- this.myDialog.update = false
- this.updateInput = ''
- },
- //获取被筛选掉的行号
- trimmedRows() {
- var plugin = this.hot.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 || [];
- },
- //去除数组中相同的元素
- 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;
- },
- //如果选择供应商之后
- supplierChange(data) {
- tools.setDataForKey(this.tableData[this.row], "DPSupplierID", data.venderId)
- tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.Supplier", data.name)
- this.handleUpdataTable(
- [
- [this.row, "DPSupplierID", null, data.venderId],
- [this.row, "LedgerParam.SupplyPurchase.Supplier", null, data.name]
- ],
- "edit"
- )
- // this.handleUpdataTable([[this.row, "LedgerParam.SupplyPurchase.Supplier", null, data.name]], "edit")
- },
- //供应合同编号
- supplyChange(data) {
- tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.SupplierContractID", { id: data })
- },
- //保险单号-保险文件
- 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")
- }
- },
- //选择型号修改
- firmChange(data) {
- tools.setDataForKey(this.tableData[this.row], "DPManufacturerID", data.venderId)//生产商ID
- tools.setDataForKey(this.tableData[this.row], "DPBrandID", data.brandId)//品牌ID
- tools.setDataForKey(this.tableData[this.row], "DPSpecificationID", data.specificationId)//型号ID
- tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Manufacturer", data.venderName)
- tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Brand", data.brandName)
- tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Specification", data.name)
- this.handleUpdataTable(
- [
- [this.row, "DPManufacturerID", null, data.venderId],
- [this.row, "DPBrandID", null, data.brandId],
- [this.row, "DPSpecificationID", null, data.specificationId],
- [this.row, "LedgerParam.EquipManufactor.Manufacturer", null, data.venderName],
- [this.row, "LedgerParam.EquipManufactor.Brand", null, data.brandName],
- [this.row, "LedgerParam.EquipManufactor.Specification", null, data.name]
- ],
- "edit"
- )
- // this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Brand", null, data.brand]], "edit")
- // this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Specification", null, data.name]], "edit")
- },
- //保险商变更
- changeInsurer(data) {
- tools.setDataForKey(this.tableData[this.row], "DPInsurerID", data.venderId)
- tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.Insurer", data.name)
- this.handleUpdataTable(
- [
- [this.row, "DPInsurerID", null, data.venderId],
- [this.row, "LedgerParam.InsuranceDoc.Insurer", null, data.name]
- ],
- "edit"
- )
- // this.handleUpdataTable([[this.row, "LedgerParam.InsuranceDoc.Insurer", null, data.name]], "edit")
- },
- //维修商变更
- changeMaintainer(data) {
- tools.setDataForKey(this.tableData[this.row], "DPMaintainerID", data.venderId)
- tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.Maintainer", data.name)
- this.handleUpdataTable(
- [
- [this.row, "DPMaintainerID", null, data.venderId],
- [this.row, "LedgerParam.OperationMainte.Maintainer", null, data.name]
- ],
- "edit"
- )
- // this.handleUpdataTable([[this.row, "LedgerParam.OperationMainte.Maintainer", null, data.name]], "edit")
- },
- //修改关联的资产
- changeProperty(val) {
- this.setDataToMain(val.PropertyId, 'PropertyId', this.row);
- this.setDataToMain(val.LinkEquipLocalName, 'LinkEquipLocalName', this.row);
- },
- //上传文件弹窗触发事件
- fileChange(keys) {
- this.setDataToMain(keys, this.messKey, this.row);
- },
- //上传图片弹窗触发事件
- imgChange(keys) {
- this.setDataToMain(keys, this.messKey, this.row);
- },
- //关联系统更改
- changeSystemType(data) {
- tools.setDataForKey(this.tableData[this.row], "LinkSystem", data)
- },
- //资产图片弹窗改变事件
- changePics(keys) {
- this.setDataToMain(keys, this.messKey, this.row);
- },
- 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);
- this.handleUpdataTable([[row, key, null, data]], "edit");
- } else {
- this.tableData[row] = {};
- tools.setDataForKey(this.tableData[row], key, data);
- }
- } else {
- tools.setDataForKey(this.tableData[row], key, "");
- }
- },
- //未知
- setGraphyId(graphyId, assetGroupList) {
- this.graphyId = graphyId
- this.assetGroupList = assetGroupList
- },
- },
- watch: {
- projectId() {
- this.buildFloorData = []
- buildFloor.getData(this.buildFloorData)
- this.main = []
- this.mess.deviceId = null
- this.page.total = 0
- },
- showTypes: {
- handler(newName, oldName) {
- if (newName && newName[0] && newName[0].value) {
- this.showType = newName[0].value
- } else {
- this.showType = ""
- }
- },
- immediate: true,
- deep: true
- }
- }
- };
- </script>
- <style lang="less">
- .hanson-bar {
- height: 40px;
- padding: 5px 0;
- font-size: 14px;
- overflow: hidden;
- margin-top: 0;
- line-height: 40px;
- .iconfont {
- font-size: 12px;
- }
- }
- .add-assets {
- .el-dialog__body {
- height: 130px;
- .die-text {
- margin-left: 10px;
- font-weight: bold;
- clear: both;
- padding-top: 25px;
- padding-bottom: 10px;
- .die-num {
- width: 100px;
- text-align: center;
- display: inline-block;
- border-bottom: 1px solid #333;
- }
- }
- }
- }
- .cancelButtonClass {
- width: 180px;
- }
- </style>
|