|
|
<template> <div class="mod-config">
<!-- 收藏 --> <div> <span @click="favoriteFunction()"> <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg> </span> </div>
<!-- 条件查询 --> <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()"> <el-form-item :label="'BU'"> <el-select v-model="searchData.buDesc" placeholder="请选择" clearable style="width: 130px"> <el-option v-for = "i in userBuList" :key = "i.buNo" :label = "i.buDesc" :value = "i.buDesc"> </el-option> </el-select> </el-form-item> <el-form-item :label="'抽样方案编码'"> <el-input v-model="searchData.samplingProgrammeNo" clearable style="width: 120px"></el-input> </el-form-item> <el-form-item :label="'抽样方案名称'"> <el-input v-model="searchData.samplingProgrammeDesc" clearable style="width: 120px"></el-input> </el-form-item> <el-form-item :label="'抽样方案代码'"> <el-input v-model="searchData.samplingProgrammeCode" clearable style="width: 120px"></el-input> </el-form-item> <el-form-item :label="' '"> <el-button v-if="!authSearch" type="primary" @click="getDataList()">查询</el-button> <el-button v-if="!authSave" type="primary" @click="addModal()">新增</el-button> <download-excel :fields="fields()" :data="exportData" type="xls" :name="exportName" :header="exportHeader" :footer="exportFooter" :fetch="createExportData" :before-generate="startDownload" :before-finish="finishDownload" worksheet="导出信息" class="el-button el-button--primary el-button--medium"> {{ "导出" }} </download-excel> </el-form-item> </el-form>
<!-- 展示列表 --> <el-table :height="height" :data="dataList" border style="width: 100%;"> <el-table-column v-for="(item,index) in columnList" :key="index" :sortable="item.columnSortable" :prop="item.columnProp" :header-align="item.headerAlign" :show-overflow-tooltip="item.showOverflowTooltip" :align="item.align" :fixed="item.fixed===''?false:item.fixed" :min-width="item.columnWidth" :label="item.columnLabel"> <template slot-scope="scope"> <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span> <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span> </template> </el-table-column> <el-table-column fixed="right" header-align="center" align="center" width="160" label="操作"> <template slot-scope="scope"> <a v-if="!authDetail" type="text" size="small" @click="detailModal(scope.row)">矩阵详情</a> <a v-if="!authDelete" type="text" size="small" @click="deleteData(scope.row)">删除</a> </template> </el-table-column> </el-table>
<!-- 分页栏 --> <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[20, 50, 100, 200, 500]" :page-size="pageSize" :total="totalPage" layout="total, sizes, prev, pager, next, jumper"> </el-pagination>
<!-- 抽样方案新增/修改 --> <el-dialog title="新增抽样方案" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="400px"> <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;"> <el-form-item label="BU" prop="bu" :rules="rules.bu"> <el-select v-model="modalData.bu" placeholder="请选择" :disabled="modalDisableFlag" style="width: 353px"> <el-option v-for = "i in userBuList" :key = "i.buNo" :label = "i.buNo" :value = "i.buNo"> <span style="float: left;width: 100px">{{ i.sitename }}</span> <span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px"> {{ i.buDesc }} </span> </el-option> </el-select> </el-form-item> </el-form> <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;"> <el-form-item label="抽样方案名称:" prop="samplingProgrammeDesc" :rules="rules.samplingProgrammeDescType"> <el-input v-model="modalData.samplingProgrammeDesc" style="width: 170px"></el-input> </el-form-item> <el-form-item label="抽样方案代码:" prop="samplingProgrammeCode" :rules="rules.samplingProgrammeCodeType"> <el-input v-model="modalData.samplingProgrammeCode" style="width: 170px"></el-input> </el-form-item> </el-form> <el-footer style="height:40px;margin-top: 10px;text-align:center"> <el-button type="primary" @click="saveData()">保存</el-button> <el-button type="primary" @click="modalFlag = false">关闭</el-button> </el-footer> </el-dialog>
<!-- 检验模板 --> <el-dialog title="矩阵详情" :close-on-click-modal="false" v-drag :visible.sync="detailModelFlag" width="1500px"> <el-form :inline="true" label-position="top"> <el-form-item :label="'抽样方案编码'"> <el-input v-model="detailData.samplingProgrammeNo" readonly style="width: 100px"></el-input> </el-form-item> <el-form-item :label="'抽样方案名称'"> <el-input v-model="detailData.samplingProgrammeDesc" readonly style="width: 150px"></el-input> </el-form-item> <el-form-item :label="'抽样方案代码'"> <el-input v-model="detailData.samplingProgrammeCode" readonly style="width: 150px"></el-input> </el-form-item> <el-form-item :label="' '"> <el-button type="primary" @click="addFastModal()">新增</el-button> </el-form-item> </el-form> <!-- 检验项目展示列表 --> <el-table :height="300" :data="detailList" border style="width: 100%;"> <el-table-column v-for="(item,index) in columnDetailList" :key="index" :sortable="item.columnSortable" :prop="item.columnProp" :header-align="item.headerAlign" :show-overflow-tooltip="item.showOverflowTooltip" :align="item.align" :fixed="item.fixed==''?false:item.fixed" :min-width="item.columnWidth" :label="item.columnLabel"> <template slot-scope="scope"> <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span> <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span> </template> </el-table-column> <el-table-column fixed="right" header-align="center" align="center" width="80" label="操作"> <template slot-scope="scope"> <a type="text" size="small" @click="deleteSamplingProgrammeDetails(scope.row)">删除矩阵</a> </template> </el-table-column> </el-table> <el-footer style="height:40px;margin-top: 20px;text-align:center"> <el-button type="primary" @click="detailModelFlag = false">关闭</el-button> </el-footer> </el-dialog>
<!-- 矩阵详情->快速新增 --> <el-dialog title="新增" @close="refreshDetailList" :close-on-click-modal="false" v-drag :visible.sync="fastAddFlag" width="900px"> <div style="font-size: 12px"> <el-form :inline="true" label-position="top" :model="detailData"> <el-form-item :label="'方案编码'"> <el-input v-model="detailData.samplingProgrammeNo" readonly style="width: 120px"></el-input> </el-form-item> <el-form-item :label="'方案名称'"> <el-input v-model="detailData.samplingProgrammeDesc" readonly style="width: 240px"></el-input> </el-form-item> </el-form> </div> <el-container style="margin-top: 0px;"> <el-main style="width: 400px;padding: 0px"> <span style="font-size: 12px" >可选矩阵:</span> <el-table height="400px" :data="itemList1" border ref="itemTable1" @row-click="itemClickRow1" @selection-change="selectionItem1" highlight-current-row style="width: 100%"> <el-table-column type="selection" header-align="center" align="center" :selectable="selectFlag" width="50"> </el-table-column> <el-table-column prop="samplingPlanNo" header-align="center" align="center" min-width="110" label="矩阵编码"> </el-table-column> <el-table-column prop="samplingPlanDesc" header-align="center" align="center" min-width="170" label="矩阵名称"> </el-table-column> </el-table> </el-main> <el-main style="width: 100px;padding: 0px"> <div style="margin-top: 182px;margin-left: 18px"> <el-button type="primary" @click="addItem()">添加>></el-button> </div> <div style="margin-top: 15px;margin-left: 18px"> <el-button type="primary" @click="deleteItem()">删除<<</el-button> </div> </el-main> <el-main style="width: 400px;padding: 0px"> <span style="font-size: 12px">已有矩阵:</span> <el-table height="400px" :data="itemList2" border ref="itemTable2" @row-click="itemClickRow2" @selection-change="selectionItem2" highlight-current-row style="width: 100%"> <el-table-column type="selection" header-align="center" align="center" :selectable="selectFlag" width="50"> </el-table-column> <el-table-column prop="samplingPlanNo" header-align="center" align="center" min-width="110" label="矩阵编码"> </el-table-column> <el-table-column prop="samplingPlanDesc" header-align="center" align="center" min-width="170" label="矩阵名称"> </el-table-column> </el-table> </el-main> </el-container> <el-footer style="height:40px;margin-top: 20px;text-align:center"> <el-button type="primary" @click="fastAddFlag = false">关闭</el-button> </el-footer> </el-dialog>
<Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist> </div></template>
<script> import { samplingProgrammeSearch, // 查询抽样方案
samplingProgrammeSave, // 新增抽样方案
samplingProgrammeDelete, // 删除抽样方案
searchSamplingProgrammeDetails, // 搜索抽样方案中的矩阵
getPlanLists, // 获取矩阵列表
saveSamplingProgrammeDetails, // 新增抽样方案中的矩阵
deleteSamplingProgrammeDetails, // 删除抽样方案中的矩阵
getSiteAndBuByUserName } from "@/api/qc/qc.js" import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js" import Chooselist from '@/views/modules/common/Chooselist_eam' import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js' export default { components: { Chooselist }, data () { return { // 是否收藏
favorite: false, // 导出 start
exportData: [], exportName: "根据物料设置检验模板" + this.dayjs().format('YYYYMMDDHHmmss'), exportHeader: ["根据物料设置检验模板"], exportFooter: [], exportList: [], // 导出 end
tagNo: '', searchData: { site: '', userName: this.$store.state.user.name, samplingProgrammeNo: '', samplingProgrammeDesc: '', samplingProgrammeCode: '', buDesc: '', page: 1, limit: 10, }, height: 200, pageIndex: 1, pageSize: 20, totalPage: 0, modalFlag: false, modalDisableFlag: false, modalData: { flag: '', site: '', bu: '', samplingProgrammeNo: '', samplingProgrammeDesc: '', samplingProgrammeCode: '', createBy: this.$store.state.user.name, updateBy: this.$store.state.user.name, }, detailData: { site: '', buNo: '', samplingProgrammeNo: '', samplingProgrammeDesc: '', samplingProgrammeCode: '', createBy: this.$store.state.user.name }, columnList: [ { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table1BuDesc', tableId: "301013Table1", tableName: "抽样方案表", columnWidth: 100, columnProp: 'buDesc', headerAlign: "center", align: "center", columnLabel: 'BU', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table1SamplingProgrammeNo', tableId: "301013Table1", tableName: "抽样方案表", columnWidth: 211, columnProp: 'samplingProgrammeNo', headerAlign: "center", align: "center", columnLabel: '抽样方案编码', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table1SamplingProgrammeDesc', tableId: "301013Table1", tableName: "抽样方案表", columnWidth: 208, columnProp: 'samplingProgrammeDesc', headerAlign: "center", align: "center", columnLabel: '抽样方案名称', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table1SamplingProgrammeCode', tableId: "301013Table1", tableName: "抽样方案表", columnWidth: 208, columnProp: 'samplingProgrammeCode', headerAlign: "center", align: "center", columnLabel: '抽样方案代码', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table1CreateTime', tableId: "301013Table1", tableName: "抽样方案表", columnWidth: 208, columnProp: 'createTime', headerAlign: "center", align: "center", columnLabel: '创建时间', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table1CreateBy', tableId: "301013Table1", tableName: "抽样方案表", columnWidth: 208, columnProp: 'createBy', headerAlign: "center", align: "center", columnLabel: '创建人', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table1UpdateDate', tableId: "301013Table1", tableName: "抽样方案表", columnWidth: 208, columnProp: 'updateDate', headerAlign: "center", align: "center", columnLabel: '更新时间', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table1UpdateBy', tableId: "301013Table1", tableName: "抽样方案表", columnWidth: 208, columnProp: 'updateBy', headerAlign: "center", align: "center", columnLabel: '更新人', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, ], detailModelFlag: false, detailList: [], itemData:{ itemNo:'', valueNo:'', availableValue:'', itemType:'D', createdBy: this.$store.state.user.name }, dataList: [], // 展示列集
columnDetailList: [ { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table2SamplingPlanNo', tableId: "301013Table2", tableName: "矩阵详情表", columnWidth: 181, columnProp: 'samplingPlanNo', headerAlign: "center", align: "center", columnLabel: '矩阵编码', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table2SamplingPlanDesc', tableId: "301013Table2", tableName: "矩阵详情表", columnWidth: 174, columnProp: 'samplingPlanDesc', headerAlign: "center", align: "center", columnLabel: '矩阵名称', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table2SamplingQtyDesc', tableId: "301013Table2", tableName: "矩阵详情表", columnWidth: 174, columnProp: 'samplingQtyDesc', headerAlign: "center", align: "center", columnLabel: '样本量字码', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table2SamplingQty', tableId: "301013Table2", tableName: "矩阵详情表", columnWidth: 174, columnProp: 'samplingQty', headerAlign: "center", align: "center", columnLabel: '样本量', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table2SamplingQtyRankDesc', tableId: "301013Table2", tableName: "矩阵详情表", columnWidth: 174, columnProp: 'samplingQtyRankDesc', headerAlign: "center", align: "center", columnLabel: '批量级次', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table2MinQty', tableId: "301013Table2", tableName: "矩阵详情表", columnWidth: 174, columnProp: 'minQty', headerAlign: "center", align: "center", columnLabel: '最小抽样数', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table2MaxQty', tableId: "301013Table2", tableName: "矩阵详情表", columnWidth: 174, columnProp: 'maxQty', headerAlign: "center", align: "center", columnLabel: '最大抽样数', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, { userId: this.$store.state.user.name, functionId: 301013, serialNumber: '301013Table2SamplingLevelDesc', tableId: "301013Table2", tableName: "矩阵详情表", columnWidth: 174, columnProp: 'samplingLevelDesc', headerAlign: "center", align: "center", columnLabel: '抽样等级', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', }, ], // 快速添加
fastAddFlag: false, itemList1: [], itemList2: [], itemListRow1: {}, itemListRow2: {}, tempLevelRow: '', tempPlanRow: '', options: [], itemSelections1: [], itemSelections2: [], rules: { samplingProgrammeDescType:[ { required: true, message: ' ', trigger: ['blur','change'] } ], samplingProgrammeCodeType:[ { required: true, message: ' ', trigger: ['blur','change'] } ], bu:[ { required: true, message: ' ', trigger: ['blur','change'] } ] }, userBuList: [], authSearch: false, authSave: false, authDetail: false, authDelete: false, menuId: this.$route.meta.menuId, } },
mounted () { this.$nextTick(() => { this.height = window.innerHeight - 210 }) },
created () { // 按钮控制
this.getButtonAuthData() // 获取用户的 site 和 bu
this.getSiteAndBuByUserName() // 校验用户是否收藏
this.favoriteIsOk() // 动态列
this.getTableUserColumn(this.$route.meta.menuId+'table1',1) this.getTableUserColumn(this.$route.meta.menuId+'table2',2) if (!this.authSearch) { // 获取数据列表
this.getDataList() } },
methods: { // 获取用户的bu
getSiteAndBuByUserName () { let tempData = { username: this.$store.state.user.name, } getSiteAndBuByUserName(tempData).then(({data}) => { if (data.code === 0) { this.userBuList = data.rows } }) },
chooseLevel (row) { this.tempLevelRow = row this.getBaseList(208) },
choosePlanRow (row) { this.tempPlanRow = row this.getBaseList(1049) },
// 获取基础数据列表S
getBaseList (val,type) { this.tagNo = val this.$nextTick(() => { let strVal = '' if (val === 208) { strVal = this.tempLevelRow.samplingLevelNo this.$refs.baseList.init(val, strVal) } if (val === 1049) { strVal = this.tempPlanRow.samplingPlanNo this.$refs.baseList.init(val, strVal) } }) },
// 列表方法的回调
getBaseData (val) { if (this.tagNo === 208) { this.tempLevelRow.samplingLevelNo = val.sampling_level_no this.tempLevelRow.samplingLevelDesc = val.sampling_level_desc } if (this.tagNo === 1049) { this.tempPlanRow.samplingPlanNo = val.sampling_plan_no } },
// 获取数据列表
getDataList () { this.searchData.limit = this.pageSize this.searchData.page = this.pageIndex samplingProgrammeSearch(this.searchData).then(({data}) => { if (data.code === 0) { this.dataList = data.page.list this.pageIndex = data.page.currPage this.pageSize = data.page.pageSize this.totalPage = data.page.totalCount } }) },
// 每页数
sizeChangeHandle (val) { this.pageSize = val this.pageIndex = 1 this.getDataList() },
// 当前页
currentChangeHandle (val) { this.pageIndex = val this.getDataList() },
addModal () { this.modalData = { flag: '1', site: '', bu: this.userBuList[0].buNo, samplingProgrammeNo: '', samplingProgrammeDesc: '', samplingProgrammeCode: '', createBy: this.$store.state.user.name, updateBy: this.$store.state.user.name, } this.modalDisableFlag = false this.modalFlag = true },
// 删除
deleteData (row) { this.$confirm(`是否删除这个抽样方案?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { samplingProgrammeDelete(row).then(({data}) => { if (data && data.code === 0) { this.getDataList() this.$message({ message: '操作成功', type: 'success', duration: 1500, onClose: () => {} }) } else { this.$alert(data.msg, '错误', { confirmButtonText: '确定' }) } }) }).catch(() => { }) },
// 新增抽样方案
saveData () { if (this.modalData.bu === '' || this.modalData.bu == null) { this.$message.warning('请选择BU!') return } if (this.modalData.samplingProgrammeDesc === '' || this.modalData.samplingProgrammeDesc == null) { this.$message.warning('请输入抽样方案名称!') return } if (this.modalData.samplingProgrammeCode === '' || this.modalData.samplingProgrammeCode == null) { this.$message.warning('请输入抽样方案代码!') return } if (this.modalData.flag === '1') { samplingProgrammeSave(this.modalData).then(({data}) => { if (data && data.code === 0) { this.getDataList() this.modalFlag = false this.$message({ message: '操作成功', type: 'success', duration: 1500, onClose: () => {} }) } else { this.$alert(data.msg, '错误', { confirmButtonText: '确定' }) } }) } },
// 打开矩阵详情
detailModal (row) { this.detailData.site = row.site this.detailData.buNo = row.buNo this.detailData.samplingProgrammeNo = row.samplingProgrammeNo this.detailData.samplingProgrammeDesc = row.samplingProgrammeDesc this.detailData.samplingProgrammeCode = row.samplingProgrammeCode searchSamplingProgrammeDetails(this.detailData).then(({data}) => { this.detailList = data.rows }) this.detailModelFlag = true },
// 新增
addFastModal () { this.itemSelections1 = null this.itemSelections2 = null getPlanLists(this.detailData).then(({data}) => { this.itemList1 = data.row1 this.itemList2 = data.row2 }) this.fastAddFlag = true },
// 可选项目
itemClickRow1 (row) { this.$refs.itemTable1.toggleRowSelection(row) },
// 已有项目
itemClickRow2 (row) { this.$refs.itemTable2.toggleRowSelection(row) },
selectFlag () { return true },
selectionItem1 (val) { this.itemSelections1 = val },
selectionItem2 (val) { this.itemSelections2 = val },
// 添加矩阵
addItem () { if (this.itemSelections1 == null || this.itemSelections1.length === 0) { this.$message.warning('请选择可选矩阵!') return } let inData = { samplingProgrammeNo: this.detailData.samplingProgrammeNo, planList: this.itemSelections1, site: this.detailData.site, buNo: this.detailData.buNo, updateBy: this.$store.state.user.name, } saveSamplingProgrammeDetails(inData).then(({data}) => { if (data && data.code === 0) { getPlanLists(this.detailData).then(({data}) => { this.itemList1 = data.row1 this.itemList2 = data.row2 }) this.itemSelections1 = [] } else { this.$alert(data.msg, '错误', { confirmButtonText: '确定' }) } }) },
// 删除矩阵
deleteItem () { if (this.itemSelections2 == null || this.itemSelections2.length === 0) { this.$message.warning('请选择已有矩阵!') return } let inData = { samplingProgrammeNo: this.detailData.samplingProgrammeNo, planList: this.itemSelections2, site: this.detailData.site, buNo: this.detailData.buNo, updateBy: this.$store.state.user.name, } deleteSamplingProgrammeDetails(inData).then(({data}) => { if (data && data.code === 0) { getPlanLists(this.detailData).then(({data}) => { this.itemList1 = data.row1 this.itemList2 = data.row2 }) this.itemSelections2 = [] } else { this.$alert(data.msg, '错误', { confirmButtonText: '确定' }) } }) },
// 关闭后刷新列表
refreshDetailList () { searchSamplingProgrammeDetails(this.detailData).then(({data}) => { this.detailList = data.rows }) },
// 删除抽样方案中的矩阵
deleteSamplingProgrammeDetails (row) { row.updateBy = this.$store.state.user.name this.$confirm(`是否删除这个矩阵?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { deleteSamplingProgrammeDetails(row).then(({data}) => { if (data && data.code === 0) { searchSamplingProgrammeDetails(this.detailData).then(({data}) => { this.detailList = data.rows }) this.$message({ message: '操作成功', type: 'success', duration: 1500, onClose: () => {} }) } else { this.$alert(data.msg, '错误', { confirmButtonText: '确定' }) } }) }).catch(() => { }) },
// 校验用户是否收藏
favoriteIsOk () { let userFavorite = { userId: this.$store.state.user.id, languageCode: this.$i18n.locale } userFavoriteList(userFavorite).then(({data}) => { for (let i = 0; i < data.list.length; i++) { if (this.$route.meta.menuId === data.list[i].menuId) { this.favorite = true } } }) },
// 收藏 OR 取消收藏
favoriteFunction () { let userFavorite = { userId: this.$store.state.user.id, functionId: this.$route.meta.menuId, } if (this.favorite) { removeUserFavorite(userFavorite).then(({data}) => { this.$message.success(data.msg) this.favorite = false }) } else { // 收藏
saveUserFavorite(userFavorite).then(({data}) => { this.$message.success(data.msg) this.favorite = true }) } },
//导出excel
async createExportData () { this.searchData.limit = -1 this.searchData.page = 1 await samplingProgrammeSearch(this.searchData).then(({data}) => { this.exportList= data.page.list }) return this.exportList },
startDownload() {},
finishDownload() {},
fields () { let json = "{" this.columnList.forEach((item, index) => { if (index == this.columnList.length - 1) { json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" } else { json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + "," } }) json += "}" let s = eval("(" + json + ")") return s },
// 动态列开始 获取 用户保存的 格式列
async getTableUserColumn (tableId, columnId) { let queryTableUser = { userId: this.$store.state.user.name, functionId: this.$route.meta.menuId, tableId: tableId, status: true, languageCode: this.$i18n.locale } await getTableUserListLanguage(queryTableUser).then(({data}) => { if (data.rows.length > 0) { //this.columnList1 = []
switch (columnId) { case 1: this.columnList = data.rows break; case 2: this.columnDetailList = data.rows break; // case 3:
// this.columnList2 = data.rows
// break;
// case 4:
// this.columnList3 = data.rows
// break;
} } else { this.getColumnList(tableId, columnId) } }) },
// 获取 tableDefault 列
async getColumnList (tableId, columnId) { let queryTable = { functionId: this.$route.meta.menuId, tableId: tableId, languageCode: this.$i18n.locale } await getTableDefaultListLanguage(queryTable).then(({data}) => { if (!data.rows.length == 0) { switch (columnId) { case 1: this.columnList = data.rows break; case 2: this.columnDetailList = data.rows break; // case 3:
// this.columnList2 = data.rows
// break;
// case 4:
// this.columnList3 = data.rows
// break;
} } else { // this.showDefault = true.
} }) },
//获取按钮的权限数据
getButtonAuthData () { let searchFlag = this.isAuth(this.menuId+":search") let saveFlag = this.isAuth(this.menuId+":save") let detailFlag = this.isAuth(this.menuId+":detail") let deleteFlag = this.isAuth(this.menuId+":delete") //处理页面的权限数据
this.authSearch = !searchFlag this.authSave = !saveFlag this.authDetail = !detailFlag this.authDelete = !deleteFlag }, } }</script>
|