12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229 |
- <template>
- <div>
- <!-- <div class="hanson-bar">
- <span>当前筛选条件下共{{page.total || '--'}}资产</span>
- <div style="width:300px;float:right;overflow:hidden;">
- <el-button size="small" @click="addDevice" icon="iconfont icon-tianjia">添加资产</el-button>
- <el-button size="small" @click="reset" icon="iconfont icon-shuaxin">刷新</el-button>
- <el-button size="small" @click="undo" icon="iconfont icon-undo">撤销</el-button>
- </div>
- </div>-->
- <div class="hanson-bar">
- <span>当前筛选条件下共{{page.total || '--'}}资产</span>
- <div style="width:300px;float:right;overflow:hidden;">
- <el-button size="small" @click="addDevice" icon="iconfont icon-tianjia">添加资产</el-button>
- <el-button size="small" @click="reset" icon="iconfont icon-shuaxin">刷新</el-button>
- <el-button size="small" @click="undo" icon="iconfont icon-undo">撤销</el-button>
- </div>
- <div style="width:200px;color:gray;float:right;padding-top:7px;font-size:10px;">
- <span v-if="!onlyRead">隐藏自动填充的信息点:</span>
- <el-tooltip v-if="!onlyRead" :content="'' + (isWatch ? '隐藏' : '不隐藏')" placement="top">
- <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-switch
- @change="changeWatch"
- v-model="allMess"
- active-color="#13ce66"
- inactive-color="gray"
- ></el-switch>
- </el-tooltip>
- </div>
- <div
- style="width:90px;cursor: pointer;color:gray;float:right; font-size:10px;padding-top:7px;"
- >
- <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 :qrcodeUrl="qrcodeUrl" :dialog="dialog" :addBody="true" ref="qrcode"></qrcode>
- <firm ref="firm" :mess="mess" @changeFirm="firmChange" :dialog="dialog"></firm>
- <supply-dialog @change="supplyChange" ref="supply" :id="id" :dialog="dialog"></supply-dialog>
- <supplier-dialog ref="supplier" @changeSupplier="supplierChange" :dialog="dialog"></supplier-dialog>
- <guarantee-dialog @change="guaranteeChange" :id="id" ref="guarantee" :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
- v-show="!main || !main.length"
- style="width:100%;text-align:center;font-size:30px;color:gray;"
- >请选择设备族</div>
- <div v-show="main && main.length" v-loading="loading" id="handsontable" ref="handsontable"></div>
- <my-pagination v-show="main && main.length" @change="getMain" :page="page"></my-pagination>
- <dialog-assets
- :assetType="[this.mess.deviceId]"
- @close="closeDialog"
- ref="assets"
- v-if="dialog.addDevice"
- :dialog="dialog"
- ></dialog-assets>
- <details-dialog :iframeSrc="iframeSrc" v-if="dialog.details" :dialog="dialog"></details-dialog>
- <look-pic :dialog="dialog" :keysArr="picsArr"></look-pic>
- </div>
- </template>
- <script>
- import { getTableHeader, getBillPropList, updateProperty, upDateTableMain, delProperty, getEquipmentFamily } 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 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 {
- 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,
- detailsDialog,
- lookPic
- },
- computed: {
- ...mapGetters("peojMess", [
- "projectId",
- "secret",
- "userId"
- ])
- },
- data() {
- return {
- 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,
- details: false,//详情页
- lookPic: false,//图片查看
- },
- row: null,//被修改的row
- filesArr: [],//保存临时的文件key
- messKey: null,
- imgsArr: [],//临时保存的图片key数组
- picsArr: [],//临时设备图片keys数组
- projId: '',
- copyMain: null,
- groupList: [],
- iframeSrc: "",
- id: "",
- isWatch: true,
- category: {},
- onlyRead: true,
- allMess: true,
- linkNameFalg: false,
- qrcodeUrl: "",//二维码图片地址
- loading: false
- };
- },
- created() {
- this.projId = this.projectId
- },
- mounted() { },
- methods: {
- changeRead() {
- this.onlyRead = !this.onlyRead
- console.log(this.onlyRead)
- this.getMain()
- },
- //获取表头
- getHeaderData(code) {
- this.mess = code
- this.page.size = 10
- this.page.currentPage = 1
- this.getEquipGroup()
- },
- getEquipGroup() {
- getEquipmentFamily(res => {
- res.Content.map(item => {
- if (item.content && item.content.length) {
- item.content.map(key => [
- this.groupList.push(key)
- ])
- }
- })
- this.getMyHeader()
- })
- },
- getMyHeader() {
- getTableHeader({
- code: this.mess.deviceId,
- ProjId: this.projId
- }).then(res => {
- this.headers = res.data.Content;
- this.getMain()
- });
- },
- //switch改变
- changeWatch() {
- this.reset()
- },
- //获取主体数据
- 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条 (默认按照创建时间从大-->小排序)
- },
- criteria: {
- id: "",
- family: [this.mess.deviceId]
- }
- },
- secret: this.secret,
- ProjId: this.projectId
- }
- if (this.mess.buildId == "all") {
- delete param.data.criteria.id
- } else if (this.mess.floorId && this.mess.floorId != "all") {
- param.data.criteria.id = this.mess.floorId
- } else if (this.mess.floorId == 'all') {
- param.data.criteria.id = this.mess.buildId
- } else {
- param.data.criteria.id = this.mess.ProjId
- }
- getBillPropList(param, res => {
- if (res.Content.length) {
- let list = []
- res.Content = res.Content.map(item => {
- item.assetsName = item.linkEquipLocalName || item.linkEquipName
- if (!!item.linkCategory) {
- this.groupList.map(child => {
- if (item.linkCategory.substring(2, 6) == child.code) {
- item.linkCategory = 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
- }
- if (!!item.infos.ServiceLife && !!!item.infos.ExpectScrapDate) {
- item.infos.ExpectScrapDate = tools.dateAddYear(new Date(), item.infos.ServiceLife)
- list.push(item)
- }
- return item
- })
- if (list.length) {
- _this.updateScrapDate(list)
- }
- _this.main = res.Content
- _this.copyMain = tools.deepCopy(res.Content)
- _this.page.total = res.Count
- if (!!_this.hot) {
- _this.hot.destroy();
- _this.hot = null;
- }
- if (!!res.Content && res.Content.length) {
- _this.initHot();
- }
- }
- this.loading = false
- })
- },
- updateScrapDate(data) {
- let param = data.map(item => {
- return {
- FmId: item.id,
- Infos: {
- ExpectScrapDate: item.infos.ExpectScrapDate
- }
- }
- })
- upDateTableMain({
- ProjId: this.projectId,
- UserId: this.userId
- }, param).then(res => {
- if (res.data.Result == "success") {
- return
- } else {
- this.$message.error("添加报废日期错误")
- }
- })
- },
- //获取动态参数
- getBatch(data) {
- console.log(this.headers, data, "data22222")
- 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.firstTag == "运行参数" || child.firstTag == "设定参数")) {
- // param.data.criterias.push({
- // id: item.id,
- // code: key
- // })
- // }
- // })
- // }
- // }
- // }
- // })
- // if (param.data.criterias.length) {
- // BeatchQueryParam(param, res => {
- // this.main = data.map(item => {
- // res.Content.map(child => {
- // if (item.id == child.id) {
- // if (!!child.data) {
- // item.infos[child.code] = child.data
- // } else {
- // item.infos[child.code] = child.error ? child.error : "无实时数值"
- // }
- // }
- // })
- // return item
- // })
- // console.log(this.main)
- // this.hot.loadData(this.main)
- // })
- // }
- // }
- },
- //撤回
- undo() {
- this.hot.undo();
- },
- //刷新
- reset() {
- this.getMain();
- },
- //添加设备
- addDevice() {
- this.dialog.addDevice = true
- this.$nextTick(() => {
- this.$refs.assets.step(0)
- this.$refs.assets.setValue([this.mess.deviceId])
- })
- },
- /**
- * 表头文案处理函数
- * @param arr header数组数据
- *
- * @return 处理好的文案
- */
- delHeader(list) {
- let arr = tools.copyArr(list)
- // 如果不是只读状态,添加四大厂商选择
- let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "X", "L", "L1", "L2", "F1", "F2"]
- if (!this.onlyRead) {
- arr = showTools.arrToArr(arr)
- readArr.push("Own")
- }
- let data = showTools.changeHeader(arr, readArr, this.onlyRead, this.isWatch, this.allMess, true)
- data.unshift("操作", "当前关联的设备");
- console.log("header", data)
- 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, true)
- data.unshift(
- {
- data: "caozuo",
- renderer: tools.lookDetails
- }, {
- data: "assetsName",
- readOnly: true
- }
- );
- if (!this.onlyRead) {
- } else {
- data.map(item => {
- item.readOnly = true
- })
- }
- 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
- }
- })
- console.log("type", data)
- 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 - 100 - 50 - 150,
- 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;
- },
- //关闭
- closeDialog(val) {
- this.$emit("getJson", val)
- },
- //表格中的点击
- 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() {
- console.log(this.main, this.copyMain)
- let params = tools.differenceArr(this.main, this.copyMain)
- console.log(params, "params")
- let _this = this
- let param = {
- secret: this.mess.secret,
- ProjId: this.mess.ProjId,
- data: {
- "criterias": []
- }
- }
- params.map(item => {
- param.data.criterias.push({ id: item.id })
- })
- console.log(params)
- delProperty(param, res => {
- _this.$message.success("删除成功")
- _this.getMain()
- })
- },
- //保险合同
- 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)
- },
- // 修改
- updateBusiness(data, change) {
- // let param = {
- // ProjId: this.mess.ProjId,
- // secret: this.mess.secret,
- // data: {
- // criterias: []
- // }
- // };
- let param = []
- //生成对应修改数据
- data.map((item, index) => {
- let arr = change[index][1].split(".");
- let info = {};
- console.log(change[index][3], "change[index][3]")
- info[arr[1]] = change[index][3];
- param.push({
- FmId: item.id,
- Infos: info
- });
- });
- // data.map((item, index) => {
- // let arr = change[index][1].split(".");
- // let info = {};
- // info[arr[1]] = [{ value: change[index][3] }];
- // param.data.criterias.push({
- // id: item.id,
- // infos: info
- // });
- // });
- // //对五大厂商进行特殊处理
- param.map(item => {
- if (!!item.Infos.DPSupplierID) {
- item.Infos.DPSupplierID = item.Infos.DPSupplierID.split("-")[0]
- }
- if (!!item.Infos.DPManufacturerID) {
- item.Infos.DPManufacturerID = item.Infos.DPManufacturerID.split("-")[0]
- }
- if (!!item.Infos.DPInsurerID) {
- item.Infos.DPInsurerID = item.Infos.DPInsurerID.split("-")[0]
- }
- if (!!item.Infos.DPMaintainerID) {
- item.Infos.DPMaintainerID = item.Infos.DPMaintainerID.split("-")[0]
- }
- if (!!item.Infos.DPSpecificationID) {
- item.Infos.DPSpecificationID = item.Infos.DPSpecificationID.split("-")[0]
- }
- for (let k in item.Infos) {
- if (item.Infos[k] == "") {
- item.Infos[k] = null
- }
- }
- return item
- })
- upDateTableMain({
- ProjId: this.projectId,
- UserId: this.userId
- }, param).then(res => {
- console.log(res)
- })
- // updateProperty(param, res => {
- // })
- },
- //获取到了正确的信息
- getInfors(infos, row) {
- //其他的开始判断
- let val = this.hot.colToProp(row.col);
- if (val == "caozuo") {
- this.iframeSrc =
- process.env.BASE_URL +
- ":8889/#/details?perjectId=" +
- this.projectId +
- "&secret=" +
- this.secret +
- "&FmId=" +
- infos.id +
- "&type=1&code=" +
- infos.family;
- this.dialog.details = true
- }
- if (val == "infos.EquipQRCode") {
- this.qrcodeUrl = this.main[row.row].infos.EquipQRCode
- if (!!this.qrcodeUrl) {
- this.dialog.qrcode = true;
- } else {
- this.$message("此设备没有设备二维码")
- }
- }
- // if (val == "infos.Brand" || val == "infos.Specification") {
- // 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.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 == "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 == "infos.DPManufacturerID") {
- this.dialog.firm = true;
- }
- 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.Supplier"
- // ) {
- // this.dialog.supplier = true;
- // }
- if (
- val == "infos.DPSupplierID"
- ) {
- this.dialog.supplier = true;
- }
- if (val == "infos.DPMaintainerID"
- ) {
- this.dialog.maintainer = true;
- }
- if (
- val == "infos.DPInsurerID"
- ) {
- this.dialog.insurer = true;
- }
- // if (
- // val == "infos.Supplier"
- // ) {
- // this.dialog.supplier = true;
- // }
- // if (val == "infos.Maintainer") {
- // this.dialog.maintainer = true;
- // }
- // if (
- // val == "infos.Insurer" ||
- // val == "infos.InsurerContactor") {
- // this.dialog.insurer = true;
- // }
- this.row = row.row
- this.messKey = val
- console.log(val, row);
- },
- //获取被筛选掉的行号
- trimmedRows() {
- // var plugin = hot.getPlugin('trimRows').trimmedRows;//获取被筛选掉的行号
- var plugin = this.hot.getPlugin("trimRows").trimmedRows;
- let dataLength = this.main.length;
- let dataArr = new Array();
- for (let i = 0; i < dataLength; i++) {
- dataArr.push(i);
- }
- if (plugin.length <= 0) {
- dataArr = undefined;
- } else {
- dataArr = this.array_diff(dataArr, plugin);
- }
- return dataArr || [];
- // var DataArray = new Array();
- // for (var i = 0; i < plugin.length; i++) {
- // // 通过行号获取数据
- // DataArray.push(this.hot.getSourceDataAtRow(plugin[i]));
- // }
- },
- 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) {
- // if (key == 'brand') {
- // this.setDataToMain(data[key], "Brand", this.row)
- // }
- // if (key == 'name') {
- // this.setDataToMain(data[key], "Specification", this.row)
- // }
- // if (key == 'venderName') {
- // this.setDataToMain(data[key], "Manufacturer", this.row)
- // }
- // if (key == 'venderId') {
- // this.setDataToMain(data[key], "DPManufacturerID", this.row)
- // }
- // if (key == 'specificationId') {
- // this.setDataToMain(data[key], "DPSpecificationID", this.row)
- // }
- if (key == "venderId") {
- data[key] = data[key] + "-" + data.name + "/" + data.brand
- this.utilToKey(key, "venderId", data, "DPManufacturerID")
- }
- this.utilToKey(key, "specificationId", data, "DPSpecificationID")
- }
- },
- //如果选择供应商之后
- supplierChange(data) {
- for (let key in data) {
- if (key == "venderId") {
- data[key] = data[key] + "-" + data.name
- this.utilToKey(key, "venderId", data, "DPSupplierID")
- }
- // if (key == 'name') {
- // this.setDataToMain(data[key], "Supplier", this.row)
- // }
- // if (key == 'email') {
- // this.setDataToMain(data[key], "SupplierEmail", this.row)
- // }
- // if (key == 'website') {
- // this.setDataToMain(data[key], "SupplierWeb", this.row)
- // }
- // if (key == 'phone') {
- // this.setDataToMain(data[key], "SupplierPhone", this.row)
- // }
- // if (key == 'fox') {
- // this.setDataToMain(data[key], "SupplierFax", this.row)
- // }
- // if (key == 'man') {
- // this.setDataToMain(data[key], "SupplierContactor", this.row)
- // }
- }
- // tools.setItem(this.deviceType.code, this.main)
- },
- //保险商变更
- changeInsurer(data) {
- for (let key in data) {
- // if (key == 'name') {
- // this.setDataToMain(data[key], "Insurer", this.row)
- // }
- // if (key == 'email') {
- // this.setDataToMain(data[key], "InsurerEmail", this.row)
- // }
- // if (key == 'website') {
- // this.setDataToMain(data[key], "InsurerWeb", this.row)
- // }
- // if (key == 'phone') {
- // this.setDataToMain(data[key], "InsurerPhone", this.row)
- // }
- // if (key == 'fox') {
- // this.setDataToMain(data[key], "InsurerFax", this.row)
- // }
- // if (key == 'man') {
- // this.setDataToMain(data[key], "InsurerContactor", this.row)
- // }
- 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) {
- // if (key == 'name') {
- // this.setDataToMain(data[key], "Maintainer", this.row)
- // }
- // if (key == 'email') {
- // this.setDataToMain(data[key], "MaintainerEmail", this.row)
- // }
- // if (key == 'website') {
- // this.setDataToMain(data[key], "MaintainerWeb", this.row)
- // }
- // if (key == 'phone') {
- // this.setDataToMain(data[key], "MaintainerPhone", this.row)
- // }
- // if (key == 'fox') {
- // this.setDataToMain(data[key], "MaintainerFax", this.row)
- // }
- // if (key == 'man') {
- // this.setDataToMain(data[key], "MaintainerContactor", this.row)
- // }
- if (key == "venderId") {
- data[key] = data[key] + "-" + data.name
- this.utilToKey(key, "venderId", data, "DPMaintainerID")
- }
- }
- // tools.setItem(this.deviceType.code, this.main)
- },
- utilToKey(key, name, data, messName) {
- if (key == name) {
- this.setDataToMain(data[key], messName, this.row)
- }
- },
- //上传文件弹窗触发事件
- fileChange(keys) {
- this.setDataToMain(keys[0], this.messKey.split(".")[1], this.row)
- // tools.setItem(this.deviceType.code, this.main)
- },
- //上传图片弹窗触发事件
- imgChange(keys) {
- this.setDataToMain(keys[0], this.messKey.split(".")[1], this.row)
- // tools.setItem(this.deviceType.code, this.main)
- },
- //设备图片弹窗改变事件
- changePics(keys) {
- this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
- // tools.setItem(this.deviceType.code, this.main)
- },
- //判断是否有值,有值赋值
- 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] = ''
- }
- }
- }
- };
- </script>
- <style lang="less">
- .hanson-bar {
- height: 40px;
- padding: 5px;
- font-size: 16px;
- overflow: hidden;
- .iconfont {
- font-size: 12px;
- }
- .el-button {
- margin-right: 10px;
- }
- }
- </style>
|