123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293 |
- <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" @click="Batch" v-show="!onlyRead" :disabled="!(tableData && tableData.length)">批量维护信息点
- </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"/>
- <upload-files-dialog
- :read="onlyRead ? true : false"
- ref="upload"
- @changeFile="fileChange"
- :keysArr="filesArr"
- :dialog="myDialog"
- :firmDataType="firmDataType"
- :infoType="infoType"
- />
- <upload-img-dialog
- :read="onlyRead ? true : false"
- @changeFile="imgChange"
- :keysArr="imgsArr"
- :dialog="myDialog"
- :firmDataType="firmDataType"
- :infoType="infoType"
- />
- <pic-dialog
- :read="onlyRead ? true : false"
- :dialog="myDialog"
- :keysArr="picsArr"
- @change="changePics"
- :firmDataType="firmDataType"
- :infoType="infoType"
- />
- <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"/>
- </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"/>
- <!-- 不支持的输入方式 -->
- <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>
- <!-- 维护信息弹窗-->
- <batchDialog
- ref="batchDialogs"
- @code="fourVendors"
- :firmName="firmName"
- :allObject="allObject"
- :page="batchPage"
- :newEnclosure="newEnclosure"
- @getAllData="getAllData"
- @multiples="multiples"
- @upDataDevice="upDataDevice"
- />
- </div>
- </template>
- <script>
- import {
- BeatchQueryParam,
- countPartsDie,
- createPropertys,
- deleteProperty,
- propertyLinkEq,
- propertyUpdate,
- queryProperty,
- updateProperty
- } from "@/api/scan/request";
- import {getDataDictionary} from "@/api/dict";
- import tools from "@/utils/scan/tools"
- import handsonUtils from "@/utils/scan/hasontableUtils"
- import showTools from "@/utils/handsontable/notShow"
- import buildFloor from '@/utils/handsontable/buildFloorData'
- import uploadFilesDialog from "@/components/dialogs/list/filesDialog"
- import uploadImgDialog from "@/components/dialogs/list/uploadImgDialog"
- import picDialog from "@/components/dialogs/list/picDialog"
- import qrcode from "@/components/business_space/lib/qrcode"
- import myPagination from "@/components/common/myPagination"
- import myCascader from "@/components/ledger/lib/assets"
- import floorCascader from "@/components/ledger/lib/floorCascader"
- import dieCascader from "@/components/ledger/lib/partsDieList"
- import {mapGetters} from "vuex"
- //图片查看
- import lookPic from "@/components/ledger/lib/lookImages"
- import Handsontable from "handsontable-pro"
- import 'handsontable-pro/dist/handsontable.full.css'
- import batchDialog from "../../dialogs/list/batchDialog";
- import dataTypeMap from "@/utils/handsontable/dataTypeMap"
- //下拉插件
- // import "@/assets/js/chosen.jquery.min";
- // import "@/assets/js/handsontable-chosen-editor";
- export default {
- components: {
- qrcode, //二维码页面
- uploadFilesDialog,
- uploadImgDialog,
- picDialog,
- myPagination,
- // dialogAssets,
- myCascader,
- floorCascader,
- dieCascader,
- // detailsDialog,
- lookPic,
- batchDialog
- },
- created() {
- buildFloor.getData(this.buildFloorData)
- },
- computed: {
- ...mapGetters("layout", ["projectId", "secret", "userId", 'group_code']),
- showTypes() {
- return this.onlyRead ?
- [{value: "Visible", label: '只看采集信息'}, {value: "all", label: '全部'}] :
- [{value: "Visible", label: '只看采集信息'}, {value: "all", label: '全部'}]
- }
- },
- data() {
- return {
- infoType: '',
- batchPage: {
- size: 100,
- sizes: [100, 200, 500, 1000],
- total: 0,
- currentPage: 1
- },
- newEnclosure: [],
- firmName: '',//维护信息显示厂家名称
- firmDataType: 'row',
- allObject: [],
- 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, //二维码弹窗
- 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: {
- editable: true,
- code: "flowBuild",
- name: "建筑楼层",
- path: "flowBuild",
- category: 'STATIC',
- dataType: "ENUM"
- }
- }, //信息点和输入方式映射表
- updateInputShow: false, //是否显示临时维护输入框
- updateInfoPoint: '',//临时维护信息点
- updateInput: '', //临时维护信息点值
- };
- },
- methods: {
- //获取表头
- getHeaderData(code) {
- this.page.currentPage = 1
- this.mess = code
- if (this.mess.deviceId) {
- let params = {
- type: this.mess.deviceId,
- orders: "sort asc, name desc",
- };
- getDataDictionary(params, res => {
- this.tableHeader = res.content;
- this.codeToDataSource = {}
- this.tableHeader.forEach(item => {
- if (item.path) {
- this.inputMap[item.path] = item
- }
- if (item.dataSource) {
- try {
- this.codeToDataSource[item.code] = {}
- item.dataSource.forEach(dic => {
- this.codeToDataSource[item.code][dic.code] = dic.name;
- })
- } catch (e) {
- console.log(e);
- }
- }
- })
- this.getTableData()
- this.getAllData()
- // 信息维护
- this.newEnclosure = res.content.filter(i => i.dataType == dataTypeMap.ATTACHMENT)
- });
- }
- },
- //获取主体数据
- getTableData() {
- this.loading = true
- //type存在发送请求
- if (!!this.mess.deviceId) {
- let param = {
- pageSize: this.page.size,
- orders: "createTime desc, localName desc, localId desc, id 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()
- }
- })
- }
- },
- //获取所以主体数据---用于维护信息
- getAllData() {
- if (!!this.mess.deviceId) {
- // 查询step2
- let params = {
- "cascade": [
- {
- "name": "building",
- "projection": [
- "localName",
- "name",
- "id"
- ]
- },
- {
- "name": "floor",
- "projection": [
- "localName",
- "name",
- "id"
- ]
- }
- ],
- filters: `family='${this.mess.deviceId}'`,
- pageSize: this.batchPage.size,
- orders: "createTime desc, equipId desc",
- pageNumber: this.batchPage.currentPage,
- "projection": [
- "buildingId",
- "floorId",
- "family",
- "localName",
- "localId",
- "equipId",
- "bimId",
- "id"
- ]
- };
- if (this.mess.buildId == "noKnow") {
- params.filters += `;buildingId isNull`
- } else if (this.mess.buildId && this.mess.buildId != "all") {
- params.filters += `;buildingId='${this.mess.buildId}'`
- }
- if (this.mess.floorId == "noKnow") {
- params.filters += `;floorId isNull`
- } else if (this.mess.floorId && this.mess.floorId != "all") {
- params.filters += `;floorId='${this.mess.floorId}'`
- }
- queryProperty(params, res => {
- this.allObject = res.content
- this.batchPage.total = res.total
- })
- }
- },
- //获取动态参数
- getBatch(data) {
- let param = {
- groupCode: this.group_code,
- appId: "datacenter",
- projectId: this.projectId,
- data: []
- };
- this.tableHeader.map(head => {
- if (head.category != 'STATIC') {
- data.map(item => {
- let cur = tools.dataForKey(item, head.path);
- if (cur) {
- param.data.push({
- objectId: item.id,
- infoCode: head.code
- });
- }
- });
- }
- });
- if (param.data.length) {
- BeatchQueryParam(param, res => {
- this.tableData = data.map(item => {
- res.data.map(child => {
- if (item.id == child.objectId) {
- if (child.data || child.data == 0) {
- this.tableHeader.map(head => {
- if (head.code == child.infoCode) {
- let contentVal = child.data
- if (this.codeToDataSource[child.infoCode]) {
- contentVal = this.codeToDataSource[child.infoCode][child.data]
- }
- tools.setDataForKey(item, head.path, contentVal);
- }
- });
- } else {
- this.tableHeader.map(head => {
- if (head.code == child.infoCode) {
- tools.setDataForKey(
- item,
- head.path,
- 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: `classCode='${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.addData.showType = this.showType
- 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: this.onlyRead ? false : {
- 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({ id: item.id })
- })
- 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 inputData = this.inputMap[val];
- this.row = row.row;
- this.messKey = val;
- this.firmDataType = 'row'
- console.log(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("开发中...")
- this.$router.push({
- path: "propertyDetails",
- query: {
- type: this.mess.deviceId,
- equipId: infos.id,
- equipName: infos.localName ? infos.localName : infos.name ? infos.name : '',
- equipCode: infos.localId ? infos.localId : '',
- data: this.tableData.map(item => {
- return {
- value: item.id,
- label: item.localName ? item.localName : item.name ? item.name : ''
- }
- })
- }
- })
- return false
- //资产二维码图片
- // case 'EquipQRCode':
- case 'defaultQRCode ':
- this.qrcodeUrl = this.tableData[row.row][val];
- 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 '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.supplierContractID': //供应合同
- case 'infos.drawing': //设备图纸
- case 'infos.installDrawing': //安装图纸
- 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.editable) {
- this.$message("该信息点的值为自动生成,不可人工维护!");
- return false;
- }
- if (!this.onlyRead && showTools.inputModeArr.indexOf(inputData.dataType) == '-1') {
- this.updateInfoPoint = val;
- this.updateInput = tools.dataForKey(this.tableData[row.row], val);
- this.myDialog.update = true;
- return false;
- }
- },
- //关闭临时维护弹窗回调
- 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;
- },
- //修改关联的资产
- changeProperty(val) {
- this.setDataToMain(val.propertyId, 'propertyId', this.row);
- this.setDataToMain(val.linkEquipLocalName, 'linkEquipLocalName', this.row);
- },
- //上传文件弹窗触发事件
- fileChange(keys, type, file) {
- if (type === 'dialog') {
- // this.information = keys
- this.newEnclosure.forEach(i => {
- if (i.path == keys) {
- this.$set(i, 'value', file)
- }
- return i
- })
- } else {
- this.setDataToMain(keys, this.messKey, this.row);
- }
- },
- //上传图片弹窗触发事件
- imgChange(keys, type, file) {
- if (type === 'dialog') {
- // this.information = keys
- this.newEnclosure.forEach(i => {
- if (i.path == keys) {
- this.$set(i, 'value', file)
- }
- return i
- })
- } else {
- this.setDataToMain(keys, this.messKey, this.row);
- }
- },
- //关联系统更改
- changeSystemType(data) {
- tools.setDataForKey(this.tableData[this.row], "linkSystem", data)
- },
- //资产图片弹窗改变事件
- changePics(keys, type, file) {
- if (type === 'dialog') {
- // this.information = keys
- this.newEnclosure.forEach(i => {
- if (i.path == keys) {
- this.$set(i, 'value', file)
- }
- return i
- })
- } else {
- 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
- },
- // 批量信息维护
- Batch() {
- this.firmDataType = 'dialog'
- this.$refs.batchDialogs.batchDialog = true
- },
- // 接受维护信息传来的code,显示弹窗
- fourVendors(code) {
- this.firmDataType = 'dialog'
- switch (code) {
- //品牌型号弹窗
- case 'dpManufacturerId':
- // this.dataFirmType = 'dia'
- this.myDialog.firm = true;
- break;
- //供应商信息弹窗
- case 'dpSupplierId':
- this.myDialog.supplier = true;
- break;
- //维修商信息弹窗
- case 'dpMaintainerId':
- this.myDialog.maintainer = true;
- break;
- //保险公司信息
- case 'dpInsurerId':
- this.myDialog.insurer = true;
- break;
- }
- },
- forValue(arr, val) {
- let enclosure = []
- arr && arr.length && arr.map(i => {
- if (i.Path == val) {
- enclosure = i.value
- }
- })
- return enclosure
- },
- multiples(val) {
- this.firmDataType = 'dialog'
- switch (val) {
- case "infos.insuranceFile": //保险文件
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.archive": //设备文档
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.checkReport": //安装质检报告
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.maintainManual": //维修保养手册
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.approachingAcceptance": //进场验收单
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.acceptanceReport": //验收报告
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.operationManual": //操作说明书
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.originalCertificate": //原厂证明
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.testReport": //检测报告
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.productCertification": //产品合格证
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.installInstruction": //安装说明书
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.drawing": //设备图纸
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.installDrawing": //安装图纸
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.supplierContract": //供应合同
- this.filesArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.installPic"://安装照片
- this.imgsArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val
- this.myDialog.uploadImgs = true;
- break;
- case "infos.nameplate"://设备铭牌照片
- this.imgsArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val
- this.myDialog.uploadImgs = true;
- break;
- //设备照片
- case "infos.pic"://设备照片
- this.picsArr = this.forValue(this.newEnclosure, val) ? this.forValue(this.newEnclosure, val) : [];
- this.infoType = val
- this.myDialog.pic = true;
- break;
- }
- },
- upDataDevice(type, data1, data2) {
- let param = { content: data1 }
- let param1 = { content: data2 }
- if (type === 1) { //增量
- //LedgerParam
- let filterParam = this.filterCheck(param, 'sole')
- let filterParam1 = this.filterCheck(param1, 'multiple')
- if (filterParam) {
- updateProperty(param, res => {
- });
- }
- if (filterParam1) {
- param1.content.map(i => {
- i.equipId = i.id
- delete i.id
- return i
- })
- setTimeout(() => {
- propertyUpdate(param1, res => {
- })
- })
- }
- }
- if (type === 2) {//覆盖
- let filterParams = this.filterCheck(param, 'sole')
- if (filterParams) {
- updateProperty(param, res => {
- });
- }
- }
- setTimeout(() => {
- this.getTableData()
- this.getAllData()
- }, 10)
- },
- filterCheck(arr, type) {
- if (type === 'sole') {
- for (let i of arr.content) {
- for (let j in i.infos) {
- if (Array.isArray(i.infos[j]) && i.infos[j].length < 1) {
- delete i.infos[j]
- }
- }
- return Object.keys(i.infos).length
- }
- } else if (type === 'multiple') {
- let nArr = [];
- arr.content.forEach(i => {
- let { equipId, ...value } = i
- nArr.push({ infos: value })
- })
- for (let j of nArr) {
- return Object.keys(j.infos).length
- }
- }
- }
- },
- 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>
|