123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356 |
- <template>
- <div style="height: calc(100% - 44.5px);padding: 0px 10px 10px;box-sizing: border-box;">
- <div class="hanson-bar">
- <span
- style="width:20px;float:left;display:block;height:20px;cursor: pointer;"
- @click="changeAssetsFalg"
- >
- <i class="el-icon-fa el-icon-fa-compass"></i>
- </span>
- <span>当前筛选条件下共{{page.total || '--'}}设备</span>
- <div style="float:right;overflow:hidden;">
- <el-button size="small" style='width: 80px;' @click="download" icon="iconfont icon-xiazai">下载</el-button>
- <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 size="small" style='width: 80px;' v-show="!onlyRead" @click="undo" icon="iconfont icon-undo">撤销</el-button>
- </div>
- <div style="width:200px;color:gray;float:right;font-size:12px;">
- <span v-if="!onlyRead">隐藏自动填充的信息点:</span>
- <el-tooltip v-if="!onlyRead" :content="'' + (isWatch ? '隐藏' : '不隐藏')" placement="top">
- <el-checkbox v-model="isWatch" @change="changeWatch"></el-checkbox>
- <!-- <el-switch
- @change="changeWatch"
- v-model="isWatch"
- active-color="#13ce66"
- inactive-color="gray"
- ></el-switch> -->
- </el-tooltip>
- <span v-if="onlyRead">只看要采集的信息</span>
- <el-tooltip v-if="onlyRead" :content="'' + (allMess ? '部分' : '全集')" placement="top">
- <el-checkbox v-model="allMess" @change="changeWatch"></el-checkbox>
- <!-- <el-switch
- @change="changeWatch"
- v-model="allMess"
- active-color="#13ce66"
- inactive-color="gray"
- ></el-switch> -->
- </el-tooltip>
- </div>
- <div
- style="width:100px;cursor: pointer;float:right; font-size:14px;margin-right:10px"
- >
- <el-select v-model="onlyRead" @change="changeRead" size="small">
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- <!-- <p v-if="onlyRead" @click="changeRead">
- <i class="iconfont icon-yulan"></i>
- <span>只读模式</span>
- </p>
- <p v-else @click="changeRead">
- <i class="iconfont icon-yulan"></i>
- <span>编辑模式</span>
- </p> -->
- </div>
- </div>
- <!-- 二维码弹窗 -->
- <qrcode :dialog="dialog" :qrcodeUrl="qrcodeUrl" :addBody="true" ref="qrcode"></qrcode>
- <!-- 型号弹窗 -->
- <firm :mess="{deviceId: deviceType.code}" ref="firm" @changeFirm="firmChange" :dialog="dialog"></firm>
- <!-- 供应商合同弹窗 -->
- <supply-dialog ref="supply" @change="supplyChange" :id="id" :dialog="dialog"></supply-dialog>
- <!-- 供应商弹窗 -->
- <supplier-dialog ref="supplier" @changeSupplier="supplierChange" :dialog="dialog"></supplier-dialog>
- <guarantee-dialog :id="id" ref="guarantee" @change="guaranteeChange" :dialog="dialog"></guarantee-dialog>
- <upload-files-dialog
- :read="onlyRead ? true : false"
- ref="upload"
- @changeFile="fileChange"
- :keysArr="filesArr"
- :dialog="dialog"
- ></upload-files-dialog>
- <upload-img-dialog
- :read="onlyRead ? true : false"
- @changeFile="imgChange"
- :keysArr="imgsArr"
- :dialog="dialog"
- ></upload-img-dialog>
- <maintainer-dialog @changeMaintainer="changeMaintainer" ref="maintainer" :dialog="dialog"></maintainer-dialog>
- <insurer-dialog @changeInsurer="changeInsurer" ref="insurer" :dialog="dialog"></insurer-dialog>
- <pic-dialog
- :read="onlyRead ? true : false"
- :dialog="dialog"
- :keysArr="picsArr"
- @change="changePics"
- ></pic-dialog>
- <div class=" middle_sty" style="height: 91%; text-align:center" v-show="!mess.deviceId && (!main || !main.length)">
- <p><i class="iconwushuju iconfont"></i>
- 请选择设备族</p>
- </div>
-
- <div class="center middle_sty" style="height: 91%" v-show="mess.deviceId && (!main || !main.length)">
- <p>
- <i class="iconwushuju iconfont"></i>
- 暂无数据
- </p>
- </div>
-
-
- <system-type :infos="systemId" :graphyId="graphyId" :dialog="dialog"></system-type>
- <!-- <div
- v-show="!main || !main.length"
- style="width:100%;text-align:center;font-size:30px;color:gray;"
- >{{ mess.deviceId ? '请选择设备族' : '无设备'}}</div> -->
- <!-- <div
- v-show="!mess.deviceId && (!main || !main.length)"
- style="width:100%;text-align:center;font-size:30px;color:gray;"
- >请选择设备族</div> -->
-
-
-
- <div v-show="mess.deviceId && main && main.length" v-loading="loading" id="handsontable" ref="handsontable"></div>
- <div v-show="mess.deviceId && main && main.length" class="right">
- <my-pagination @change="getMain" :page="page"></my-pagination>
- </div>
- <dialog-assets
- @close="getClose"
- :graphyId="graphyId"
- :assetType="[this.mess.deviceId]"
- ref="assets"
- :dialog="dialog"
- ></dialog-assets>
- <details-dialog :iframeSrc="iframeSrc" v-if="dialog.details" :dialog="dialog"></details-dialog>
- <change-rea @close="reset" :dialog="dialog" :category="category"></change-rea>
- <look-pic :dialog="dialog" :keysArr="picsArr"></look-pic>
- </div>
- </template>
- <script>
- import { getTableHeader, getSpaceFloor, getEquipmentFamily, getBillEquipList, BeatchQueryParam, delBatchList, updateBusiness } from "@/api/scan/request";
- import tools from "@/utils/scan/tools";
- import handsonUtils from "@/utils/hasontableUtils"
- import showTools from "@/utils/handsontable/notShow"
- import text from "@/utils/handsontable/mainText"
- import qrcode from "@/components/ledger/lib/qrcode";
- import firm from "@/components/dialogs/list/firm";
- import supplyDialog from "@/components/dialogs/list/supplyDialog";
- import supplierDialog from "@/components/dialogs/list/supplierDialog";
- import maintainerDialog from "@/components/dialogs/list/maintainerDialog";
- import insurerDialog from "@/components/dialogs/list/insurerDialog";
- import guaranteeDialog from "@/components/dialogs/list/guaranteeDialog";
- import uploadFilesDialog from "@/components/dialogs/list/filesDialog";
- import uploadImgDialog from "@/components/dialogs/list/uploadImgDialog";
- import picDialog from "@/components/dialogs/list/picDialog"
- import systemType from "@/components/dialogs/list/systemType"
- import myPagination from "@/components/ledger/lib/myPagination";
- import dialogAssets from "@/components/dialogs/addDialog/dialogDevice";
- import detailsDialog from "@/components/ledger/lib/detailsDia"
- import changeRea from "@/components/dialogs/changeRea"
- //图片查看
- import lookPic from "@/components/ledger/lib/lookImages"
- //下拉插件
- import "@/assets/js/chosen.jquery.min";
- import "@/assets/js/handsontable-chosen-editor";
- import {mapGetters, mapActions} from "vuex";
- import Handsontable from "handsontable-pro"
- import 'handsontable-pro/dist/handsontable.full.css'
- import zhCN from 'handsontable-pro/languages/zh-CN';
- export default {
- props: ["myParam"],
- components: {
- qrcode, //二维码页面
- firm, //
- supplyDialog,
- supplierDialog,
- guaranteeDialog,
- uploadFilesDialog,
- maintainerDialog,
- insurerDialog,
- uploadImgDialog,
- picDialog,
- myPagination,
- dialogAssets,
- systemType,
- detailsDialog,
- changeRea,
- lookPic
- },
- data() {
- return {
- options: [{
- value: true,
- label: '只读模式'
- }, {
- value: false,
- label: '编辑模式'
- }],
- main: [],
- mess: {},
- headers: null,
- page: {
- size: 50,
- sizes: [10, 30, 50, 100, 150, 200],
- total: 0,
- currentPage: 1
- },
- dialog: {
- 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,//图片查看
- },
- row: null,//被修改的row
- filesArr: [],//保存临时的文件key
- messKey: null,
- imgsArr: [],//临时保存的图片key数组
- picsArr: [],//临时设备图片keys数组
- projId: "",
- copyMain: null,
- graphyId: null,
- systemId: null,
- assetGroupList: [],
- iframeSrc: "",
- id: 0,
- isWatch: true,
- category: {},
- onlyRead: true,
- allMess: true,
- linkNameFalg: false,
- qrcodeUrl: "",//二维码图片地址
- loading: false,
- EquipmentList: [],//资产族
- deviceType: {},
- floorData: []
- };
- },
- created() {
- this.getEquipmentFamilyList()
- this.getFloorData()
- },
- computed: {
- ...mapGetters("layout", [
- "projectId",
- "secret",
- "userId"
- ])
- },
- methods: {
- //获取楼层数据
- getFloorData() {
- let param = {
- ProjId: this.projectId,
- secret: this.secret
- }
- getSpaceFloor(param).then(res => {
- if (res.data.Result == 'success') {
- let data = this.changeArr(res.data.Content), floorData = []
- data.map(item => {
- if (!!item.children) {
- item.children.unshift({
- value: '',
- label: "未明确楼层"
- })
- }
- return item
- })
- data.map(item => {
- if (!!item.children && item.children.length) {
- item.children.map(child => {
- floorData.push({
- Code: item.value + "-" + child.value,
- Name: item.label + "-" + child.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,
- }
- }
- })
- },
- changeRead() {
- this.getHeaderData(this.mess)
- },
- getEquipmentFamilyList() {
- getEquipmentFamily(res => {
- this.EquipmentList = res.Content
- })
- },
- //触发父组件change
- getClose(val) {
- this.$emit("close", val)
- },
- setGraphyId(graphyId, assetGroupList) {
- this.graphyId = graphyId
- this.assetGroupList = assetGroupList
- },
- //获取表头
- getHeaderData(code) {
- this.page.currentPage = 1
- this.mess = code
- this.changeCader()
- if(this.mess.deviceId){
- getTableHeader({
- code: this.mess.deviceId,
- ProjId: this.projectId
- }).then(res => {
- this.headers = res.data.Content;
- this.getMain()
- });
- }
-
- },
- //获取主体数据
- getMain() {
- let _this = this
- this.loading = true
- let param = {
- data: {
- customInfo: true,
- "limit": { // 分页查询, 选填.
- "skip": this.page.size * (this.page.currentPage - 1), // 跳过多少数据
- "count": this.page.size // 查询跳过300条数据之后的50条 (默认按照创建时间从大-->小排序)
- },
- id: "",
- type: [this.mess.deviceId]
- },
- secret: this.secret,
- ProjId: this.projectId
- }
- if (this.mess.buildId == "all") {
- param.data.id = this.mess.ProjId
- } else if (this.mess.buildId == "noKnow") {
- param.data.id = this.mess.ProjId
- param.data.direct = true
- } else if (this.mess.floorId == "noKnow") {
- param.data.id = this.mess.buildId
- param.data.direct = true
- } else if (this.mess.floorId && this.mess.floorId != "all") {
- param.data.id = this.mess.floorId
- } else if (this.mess.floorId == 'all') {
- param.data.id = this.mess.buildId
- } else {
- param.data.id = this.mess.ProjId
- }
- //type存在发送请求
- if (!!this.mess.deviceId) {
- getBillEquipList(param, res => {
- if (res.Result == "success") {
- this.loading = false
- res.Content = res.Content.map(item => {
- item.linkName = item.linkEquipLocalName || item.linkEquipName
- if (!!item.linkFamily) {
- this.assetGroupList.map(child => {
- if (item.linkFamily == child.code) {
- item.linkFamily = child.name
- }
- })
- }
- if (!!item.infos.DPManufacturerID) {
- item.infos.DPManufacturerID = item.infos.DPManufacturerID + "-" + item.infos.Brand + "/" + item.infos.Specification
- }
- if (!!item.infos.DPSupplierID) {
- item.infos.DPSupplierID = item.infos.DPSupplierID + "-" + item.infos.Supplier
- }
- if (!!item.infos.DPMaintainerID) {
- item.infos.DPMaintainerID = item.infos.DPMaintainerID + "-" + item.infos.Maintainer
- }
- if (!!item.infos.DPInsurerID) {
- item.infos.DPInsurerID = item.infos.DPInsurerID + "-" + item.infos.Insurer
- }
- return item
- })
- if (_this.onlyRead) {
- this.getBatch(res.Content)
- }
- _this.main = res.Content
- // debugger
- _this.copyMain = tools.deepCopy(res.Content)
- _this.page.total = res.TotalCount
- if (!!_this.hot) {
- _this.hot.destroy();
- _this.hot = null;
- }
- if (!!res.Content && res.Content.length) {
- _this.initHot();
- }
- } else {
- this.loading = false
- this.$message.error("请求错误:" + res.ResultMsg)
- }
- })
- }
- },
- //获取动态参数
- getBatch(data) {
- let param = {
- secret: this.secret,
- ProjId: this.projectId,
- data: {
- criterias: []
- }
- }
- if (!!data && data.length) {
- //一级遍历list
- data.map(item => {
- if (!!item.infos) {
- // 二级遍历对象infos
- for (let key in item.infos) {
- //判断是否是设定参数和动态参数
- if (!!item.infos[key]) {
- this.headers.map(child => {
- //如果一级标签为动态参数或者设定参数放入数据等待请求
- if (key == child.InfoPointCode && (child.InputMode == "L" || child.InputMode == "L1" || child.InputMode == "L2")) {
- param.data.criterias.push({
- id: item.id,
- code: key
- })
- }
- })
- }
- }
- }
- })
- if (param.data.criterias.length) {
- BeatchQueryParam(param, res => {
- if (!this.onlyRead) {
- return false
- }
- this.main = data.map(item => {
- res.Content.map(child => {
- if (item.id == child.id) {
- if (!!child.data || child.data == 0) {
- item.infos[child.code] = child.data
- } else {
- item.infos[child.code] = child.error ? "表号功能号格式错误" : "表号功能号不存在"
- }
- }
- })
- return item
- })
- this.hot.loadData(this.main)
- })
- }
- }
- },
- changeAssetsFalg() {
- if (this.linkNameFalg) {
- this.linkNameFalg = false
- } else {
- this.$confirm('<p>真的要在这里修改设备关联的资产么?</p><p>真的能通过列表信息找到想关联的资产么?</p><p>在这里修改关联的资产一定是因为之前关联错了要修改么?</p>', '提示', {
- dangerouslyUseHTMLString: true,
- confirmButtonText: '没错!我要改关联的资产',
- cancelButtonText: '我就点开看看',
- confirmButtonClass: 'cancelButtonClass',
- cancelButtonClass: 'cancelButtonClass'
- }).then(_ => {
- this.linkNameFalg = true
- }).catch(_ => {
- this.$message("取消")
- })
- }
- },
- //switch改变
- changeWatch() {
- this.reset()
- },
- //撤回
- undo() {
- this.hot.undo();
- },
- //刷新
- reset() {
- this.getMain();
- },
- //添加设备
- addDevice() {
- this.dialog.addDevice = true
- this.$nextTick(() => {
- this.$refs.assets.step(0)
- })
- },
- //下载
- download() {
- if (!this.onlyRead) {
- if (!!this.hot) {
- let fileName = this.mess.name + "-页数:" + this.page.currentPage + "-个数:" + this.main.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("下载需在编辑状态下")
- }
- },
- /**
- * 表头文案处理函数
- * @param list header数组数据
- *
- * @return 处理好的文案
- */
- delHeader(list) {
- let arr = tools.copyArr(list)
- // 如果不是只读状态,添加四大厂商选择
- if (!this.onlyRead) {
- // arr = showTools.arrToArr(arr)
- }
- let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "X", "L", "L1", "L2", "F1", "F2"]
- if (!this.onlyRead) {
- readArr.push("Own")
- }
- let data = showTools.changeHeader(arr, readArr, this.onlyRead, this.isWatch, this.allMess)
- data.unshift("操作", "当前关联的资产", "所属系统实例", "包含的部件");
- return data;
- },
- /**
- * 表头数据处理函数
- * @param list header数组数据
- *
- * @return 处理好的数据格式
- */
- getType(list) {
- let arr = tools.copyArr(list)
- // 如果不是只读状态,添加四大厂商选择
- if (!this.onlyRead) {
- // arr = showTools.arrToArr(arr)
- }
- let data = showTools.showTypes(arr, this.onlyRead, this.isWatch, this.allMess)
- data.map(item => {
- if (
- item.data == "infos." + "Drawing" ||
- item.data == "infos." + "Pic" ||
- item.data == "infos." + "Nameplate" ||
- item.data == "infos." + "InstallPic" ||
- item.data == "infos." + "InstallDrawing"
- ) {
- item.renderer = text.picType
- }
- if (item.data == "infos." + "Archive" ||
- item.data == "infos." + "CheckReport" ||
- item.data == "infos." + "InsuranceFile") {
- item.renderer = text.fileType
- }
- })
- data.unshift(
- {
- data: "caozuo",
- renderer: tools.lookDetails,
- readOnly: true
- },
- {
- data: "linkName",
- readOnly: true
- }, {
- data: "linkSystem",
- renderer: text.systemList,
- readOnly: true
- }, {
- data: "Count",
- readOnly: true,
- renderer: tools.lookDetails
- }
- );
- // data.splice(1, 0, {
- // data: "flowBuild",
- // renderer: tools.customDropdownRenderer,
- // editor: "chosen",
- // chosenOptions: {
- // // multiple: true,//多选
- // data: this.floorData
- // }
- // })
- if (!!this.onlyRead) {
- data.map(item => {
- item.readOnly = true
- })
- }
- return data;
- },
- messShow(item) {
- //二维码
- if (item.infopoint_code == "EquipQRCode") {
- return {
- data: "infos." + item.infopoint_code,
- renderer: text.lookQRCode,
- readOnly: true
- }
- }
- if (item.collection_cmpt_code == "Enum") {
- return {
- data: "infos." + item.infopoint_code,
- renderer: this.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- // multiple: true,//多选
- data: item.dataSource || ""
- }
- };
- } else if (item.collection_cmpt_code == "Num") {
- return {
- data: "infos." + item.infopoint_code,
- 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.collection_cmpt_code == "Time") {
- return {
- data: "infos." + item.infopoint_code,
- type: "date",
- dateFormat: "YYYY-MM-DD",
- correctFormat: true
- };
- } else if (item.collection_cmpt_code == "text") {
- return {
- data: "infos." + item.infopoint_code
- };
- } else if (
- (item.info_point_code == "设备ID" ||
- item.info_point_code == "设备名称")
- ) {
- return {
- data: "infos." + item.infopoint_code,
- readOnly: true
- };
- } else if (item.collection_cmpt_code == "checkBox") {
- return {
- data: "infos." + item.infopoint_code,
- renderer: this.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- multiple: true,//多选
- data: item.dataSource || ""
- }
- };
- } else {
- return {
- data: "infos." + item.infopoint_code,
- }
- }
- },
- changeItem(item) {
- //二维码
- if (item.infopoint_code == "EquipQRCode" && item.visible) {
- return {
- data: "infos." + item.infopoint_code,
- renderer: text.lookQRCode,
- readOnly: true
- }
- }
- //厂商选择
- // if ((item.infopoint_code == "Brand" || item.infopoint_code == "Specification") && item.visible) {
- // return {
- // data: "infos." + item.infopoint_code,
- // renderer: tools.lookDetails,
- // readOnly: true
- // }
- // }
- // if (item.infopoint_code == "SupplierContractID" && item.visible) {
- // return {
- // data: "infos." + item.infopoint_code,
- // renderer: tools.lookDetails,
- // readOnly: true
- // }
- // }
- if (item.infopoint_code == "InsuranceNum" && item.visible) {
- //选择保单
- return {
- data: "infos." + item.infopoint_code,
- renderer: tools.lookDetails,
- readOnly: true
- }
- }
- if ((item.infopoint_code == "InsuranceFile" || item.infopoint_code == "Archive") && item.visible) {
- return {
- data: "infos." + item.infopoint_code,
- renderer: tools.lookDetails,
- readOnly: true
- }
- }
- if (
- (
- item.infopoint_code == "InstallPic" ||
- item.infopoint_code == "InstallDrawing" ||
- item.infopoint_code == "Nameplate" ||
- item.infopoint_code == "Pic" ||
- item.infopoint_code == "Drawing"
- ) && item.visible
- ) {
- return {
- data: "infos." + item.infopoint_code,
- renderer: tools.lookDetails,
- readOnly: true
- }
- }
- if (
- (
- item.infopoint_code == "Maintainer" ||
- item.infopoint_code == "Supplier" ||
- item.infopoint_code == "Insurer" ||
- item.infopoint_code == "InsurerContactor"
- )
- && item.visible
- ) {
- return {
- data: "infos." + item.infopoint_code,
- }
- }
- if (item.collection_cmpt_code == "Enum" && item.visible) {
- return {
- data: "infos." + item.infopoint_code,
- renderer: this.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- // multiple: true,//多选
- data: item.dataSource || ""
- }
- };
- } else if (item.collection_cmpt_code == "Num" && item.visible) {
- return {
- data: "infos." + item.infopoint_code,
- 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.collection_cmpt_code == "Time" && item.visible) {
- return {
- data: "infos." + item.infopoint_code,
- type: "date",
- dateFormat: "YYYY-MM-DD",
- correctFormat: true
- };
- } else if (item.collection_cmpt_code == "text" && item.visible) {
- return {
- data: "infos." + item.infopoint_code
- };
- } else if (
- (item.info_point_code == "设备ID" ||
- item.info_point_code == "设备名称") && item.visible
- ) {
- return {
- data: "infos." + item.infopoint_code,
- readOnly: true
- };
- } else if (item.collection_cmpt_code == "checkBox" && item.visible) {
- return {
- data: "infos." + item.infopoint_code,
- renderer: this.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- multiple: true,//多选
- data: item.dataSource || ""
- }
- };
- } else if (item.collection_cmpt_code == "Own" && item.visible) {
- return {
- data: "infos." + item.infopoint_code,
- renderer: text.idType,
- }
- } else {
- return undefined
- }
- },
- //初始化插件
- initHot() {
- var container = document.getElementById("handsontable");
- let winHeight = document.documentElement.clientHeight;
- this.hot = new Handsontable(container, {
- data: this.main,
- fixedColumnsLeft: 5,
- colHeaders: this.delHeader(this.headers), //表头文案
- columns: this.getType(this.headers), //数据显示格式
- filters: true,
- maxRows: this.main.length,
- height: winHeight - 335,
- columnSorting: true, //添加排序
- sortIndicator: true, //添加排序
- renderAllRows: true,
- // 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.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;
- },
- //表格中的点击
- 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.main[trimmedArr[sortArr[rowArr.row]]];
- this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col });
- } else if (isSort) {
- //排序后的数组
- let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
- let infos = this.main[sortArr[rowArr.row]];
- this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col });
- } else if (trimmedArr.length) {
- let infos = this.main[trimmedArr[rowArr.row]];
- this.getInfors(infos, { row: trimmedArr[rowArr.row], col: rowArr.col });
- } else {
- let infos = this.main[rowArr.row];
- this.getInfors(infos, rowArr);
- }
- },
- tdChange(changeData, source) {
- if (!this.onlyRead) {
- 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.updateBusiness(data, changeData);
- }
- }
- }
- },
- //删除资产
- romoveFm() {
- let params = tools.differenceArr(this.main, this.copyMain)
- let _this = this
- if (params.length < 1) {
- return
- }
- let param = {
- secret: this.mess.secret,
- ProjId: this.mess.ProjId,
- data: {
- "criterias": []
- }
- }
- params.map(item => {
- param.data.criterias.push({ id: item.id })
- })
- this.$confirm("此操作将删除设备,是否继续?", "提示", {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.removeSys(param)
- }).catch(() => {
- this.reset()
- this.$message("取消删除")
- })
- // delProperty(param, res => {
- // _this.$message.success("删除成功")
- // _this.getMain()
- // })
- },
- async removeSys(param) {
- await delBatchList(param, res => {
- this.$message.success("删除成功")
- this.getMain()
- })
- },
- // 修改
- updateBusiness(data, change) {
- // data.map(item => {
- // if (!!item.flowBuild) {
- // item.building_id = item.flowBuild.split("-")[0]
- // item.floor_id = item.flowBuild.split("-")[1] || null
- // //不存在floor字段去除floor
- // if (!item.floor_id) {
- // delete item.floor_id
- // }
- // delete item.flowBuild
- // }
- // })
- let param = {
- ProjId: this.mess.ProjId,
- secret: this.mess.secret,
- data: {
- criterias: []
- }
- };
- //生成对应修改数据
- data.map((item, index) => {
- let arr = change[index][1].split(".");
- let info = {};
- info[arr[1]] = [{ value: item[arr[0]][arr[1]] != "" ? item[arr[0]][arr[1]] : null }];
- param.data.criterias.push({
- id: item.id,
- infos: info
- });
- });
- //对五大厂商进行特殊处理
- param.data.criterias.map(item => {
- if (!!item.infos.DPSupplierID) {
- item.infos.DPSupplierID[0].value = item.infos.DPSupplierID[0].value.split("-")[0]
- }
- if (!!item.infos.DPManufacturerID) {
- item.infos.DPManufacturerID[0].value = item.infos.DPManufacturerID[0].value.split("-")[0]
- }
- if (!!item.infos.DPInsurerID) {
- item.infos.DPInsurerID[0].value = item.infos.DPInsurerID[0].value.split("-")[0]
- }
- if (!!item.infos.DPMaintainerID) {
- item.infos.DPMaintainerID[0].value = item.infos.DPMaintainerID[0].value.split("-")[0]
- }
- if (!!item.infos.DPSpecificationID) {
- item.infos.DPSpecificationID[0].value = item.infos.DPSpecificationID[0].value.split("-")[0]
- }
- return item
- })
- updateBusiness(param).then(res => {
- });
- },
- //修改设备类型
- changeCader() {
- this.EquipmentList.map(item => {
- if (!!item.content && item.content.length) {
- item.content.map(child => {
- if (child.code == this.mess.deviceId) {
- this.deviceType.assetType = item.code
- this.deviceType.assetName = item.name
- }
- })
- }
- })
- },
- //获取到了正确的信息
- getInfors(infos, row) {
- //其他的开始判断
- let val = this.hot.colToProp(row.col);
- this.row = row.row
- this.messKey = val
- this.systemId = infos.id
- if (val == "caozuo") {
- window.open(`http://47.94.89.44:8058/spread?id=${infos.id}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
- // this.iframeSrc =
- // process.env.BASE_URL +
- // ":8889/#/details?perjectId=" +
- // this.projectId +
- // "&secret=" +
- // this.secret +
- // "&FmId=" +
- // infos.id +
- // "&type=1&code=" +
- // infos.category.substring(2, 6);
- // this.dialog.details = true
- }
- //图片弹窗
- if (
- val == "infos.InstallPic" ||
- val == "infos.InstallDrawing" ||
- val == "infos.Nameplate" ||
- val == "infos.Drawing"
- ) {
- if (this.onlyRead) {
- this.dialog.lookPic = true
- this.picsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
- } 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.dialog.uploadImgs = true
- }
- }
- if (val == "linkSystem") {
- this.dialog.systemType = true
- }
- //列表少包含的部件字段目前用当前关联的资产
- if (val == "Count") {
- let partsVal = this.hot.getDataAtCell(row.row,row.col);//获取被点击的单元格的数据
- if(this.onlyRead){
- this.$router.push({ path: '/ledger/parts', query: { deviceId: infos.infos.EquipID }});
- }else{
- this.$router.push({ path: '/ledger/partsmanage', query: { deviceId: infos.infos.EquipID,typeId: this.mess.deviceId }});
- }
- }
- if (val == "infos.Pic") {
- this.picsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
- if (this.onlyRead) {
- this.dialog.lookPic = true
- } else {
- this.dialog.pic = true
- }
- }
- if (val == "infos.InsuranceFile" || val == "infos.Archive" || val == "infos.CheckReport") {
- this.filesArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
- this.dialog.uploadFiles = true
- }
- if (val == "linkName" && this.linkNameFalg) {
- this.category = this.main[row.row]
- this.dialog.changeRea = true
- }
- if (val == "infos.EquipQRCode") {
- this.qrcodeUrl = this.main[row.row].infos.EquipQRCode
- if (!!this.qrcodeUrl) {
- this.dialog.qrcode = true;
- } else {
- this.$message("此设备没有设备二维码")
- }
- }
- if (this.onlyRead) {
- return
- }
- if (val == "infos.DPManufacturerID") {
- this.dialog.firm = true;
- }
- if (val == "infos.SupplierContractID") {
- let falg = null
- if (!!this.main[row.row].infos) {
- if (!!this.main[row.row].infos.DPSupplierID) {
- falg = this.main[row.row].infos.DPSupplierID.split("-")[0]
- }
- }
- if (!!falg) {
- this.id = falg
- this.dialog.supply = true;
- } else {
- this.$message("请先选择供应商")
- }
- }
- if (val == "infos.InsuranceNum") {
- //选择保单
- let falg = null
- if (!!this.main[row.row].infos) {
- if (!!this.main[row.row].infos.DPInsurerID) {
- falg = this.main[row.row].infos.DPInsurerID.split("-")[0]
- }
- }
- if (!!falg) {
- this.id = falg
- this.dialog.guarantee = true;
- } else {
- this.$message("请先选择保险商")
- }
- }
- if (
- val == "infos.DPSupplierID"
- ) {
- if (!!infos.linkId) {
- this.dialog.supplier = true;
- } else {
- this.$message("该设备无关联资产")
- }
- }
- if (val == "infos.DPMaintainerID") {
- if (!!infos.linkId) {
- this.dialog.maintainer = true;
- } else {
- this.$message("该设备无关联资产")
- }
- }
- if (
- val == "infos.DPInsurerID") {
- if (!!infos.linkId) {
- this.dialog.insurer = true;
- } else {
- this.$message("该设备无关联资产")
- }
- }
- },
- //获取被筛选掉的行号
- 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]));
- // }
- },
- //去除数组中相同的元素
- 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) {
- for (let key in data) {
- if (key == "venderId") {
- data[key] = data[key] + "-" + data.name
- 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) {
- 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")
- }
- // tools.setItem(this.deviceType.code, this.main)
- },
- //选择型号修改
- firmChange(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")
- if (key == "venderId") {
- data[key] = data[key] + "-" + data.name + "/" + data.brand
- this.utilToKey(key, "venderId", data, "DPManufacturerID")
- }
- this.utilToKey(key, "specificationId", data, "DPSpecificationID")
- }
- },
- //保险商变更
- changeInsurer(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")
- if (key == "venderId") {
- data[key] = data[key] + "-" + data.name
- 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")
- if (key == "venderId") {
- data[key] = data[key] + "-" + data.name
- this.utilToKey(key, "venderId", data, "DPMaintainerID")
- }
- }
- // tools.setItem(this.deviceType.code, this.main)
- },
- //上传文件弹窗触发事件
- fileChange(keys) {
- this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
- // tools.setItem(this.deviceType.code, this.main)
- },
- //上传图片弹窗触发事件
- imgChange(keys) {
- this.setDataToMain(keys, 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)
- },
- utilToKey(key, name, data, messName) {
- if (key == name) {
- this.setDataToMain(data[key], messName, this.row)
- }
- },
- //判断是否有值,有值赋值
- setDataToMain(data, key, row) {
- if (!!data && data != '--') {
- if (!!this.main[row].infos) {
- //falg确定每个的是否有值
- this.main[row].infos[key] = data
- this.updateBusiness([this.main[row]], [[0, "infos." + key, null, data]])
- } else {
- this.main[row].infos = {}
- this.main[row].infos[key] = data
- }
- } else {
- this.main[row].infos[key] = ''
- }
- }
- },
- watch: {
- projectId(){
- this.main = []
- this.mess.deviceId = null
- this.page.total = 0
- }
- }
- };
- </script>
- <style lang="less">
- .hanson-bar {
- height: 40px;
- padding: 5px 10px;
- font-size: 14px;
- overflow: hidden;
- margin-top: 0;
- line-height: 40px;
- .iconfont {
- font-size: 12px;
- }
- .el-button {
- // margin-right: 10px;
- }
- }
- .cancelButtonClass {
- width: 180px;
- }
- </style>
|