<a-table>->Column-> customRender

正确示例:

<a-table :columns="columns" :data-source="tableData">
      <span slot="status" slot-scope="record">
        <a> {{ record.status === 0 ? '正常' : '禁用' }}</a>
      </span>
</a-table>
{
  title: '状态',
  key: 'status',
  // 采用dataIndex方式,需要将tableData里的status转换成正常和禁用
  // 觉得不应该去修改原接口返回数据,且是为了做展示去修改成展示值
  // 再来就是后续其他地方使用tableData时还是期望使用0和1
  // dataIndex: 'status',
  scopedSlots: { customRender: 'status' },
},

问题描述:

接口返回的status是0和-1,页面期望展示成正常和禁用。

若采用dataIndex方式,需要将tableData里的status转换成正常和禁用,觉得为了做展示去把tableData中status的值修改成展示值,不是很合理,且后续其他地方使用tableData时还是期望使用0和1

解决方法:

使用Column的customRender借助插槽来完成页面展示

 

<template> <a-card :class="$style.wrapHeight"> <!-- 普通搜索区域(替换原来的高级搜索) --> <a-card :class="$style.searchWrap"> <a-form-model ref="searchForm" class="ant-advanced-search-form" :model="factConfirmAdvSearchForm" :rules="rules" v-bind="formItemLayout" > <a-row> <a-col :span="8"> <a-form-model-item :label="'\u2002年度'" prop="timeRange" > <AuditRangePicker ref = "rangePicker" v-model="factConfirmAdvSearchForm.timeRange" :time-range.sync="factConfirmAdvSearchForm.timeRange" /> </a-form-model-item> </a-col> <a-col :span="8"> <a-form-model-item label="审计机构" prop="unitNames"> <AuditGroupPicker ref="unitNames" v-model="factConfirmAdvSearchForm.unitNames" :single="false" :read-only="false" :root-node="rootNode" /> </a-form-model-item> </a-col> <a-col :span="8"> <a-form-model-item label="项目名称" prop="projectName"> <a-input v-model="factConfirmAdvSearchForm.projectName" /> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="8"> <a-form-model-item :label="'\u2002\u2002被审计部门'" prop="auditedUnitNames"> <sd-group-picker v-model="factConfirmAdvSearchForm.auditedUnitNames" /> </a-form-model-item> </a-col> <a-col :span="8"> <a-form-model-item label="问题名称" prop="problemName"> <a-input v-model="factConfirmAdvSearchForm.problemName" /> </a-form-model-item> </a-col> <a-col :span="8"> <a-form-model-item label="业务类别" prop="problemType"> <a-input v-model="factConfirmAdvSearchForm.problemType" /> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="8"> <a-form-model-item :label="'\u2002\u2002\u2002\u2002风险等级'" prop="riskLevel"> <sd-select v-model="factConfirmAdvSearchForm.riskLevel" :options="riskLevelOption" :class="$style.select" allowClear /> </a-form-model-item> </a-col> <a-col :span="8"> <a-form-model-item label="新老问题" prop="isNewproblems"> <sd-select v-model="factConfirmAdvSearchForm.isNewproblems" :options="isNewproblemsOption" :class="$style.select" allowClear /> </a-form-model-item> </a-col> <a-col :span="8"> <a-form-model-item label="问题来源" prop="problemSource"> <sd-select v-model="factConfirmAdvSearchForm.problemSource" :options="problemSourceOption" :class="$style.select" allowClear /> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="8"> <a-form-model-item label="问题确认状态" prop="feedbackStatus"> <sd-select v-model="factConfirmAdvSearchForm.feedbackStatus" :options="feedbackStatusOption" :class="$style.select" allowClear /> </a-form-model-item> </a-col> <a-col :span="8"> <a-form-model-item label="项目来源" prop="projectSourceType"> <a-radio-group v-model="factConfirmAdvSearchForm.projectSourceType"> <a-radio v-for="option in projectSourceOptions" :key="option.id" :value="option.id"> {{ option.text }} </a-radio> </a-radio-group> </a-form-model-item> </a-col> <a-col :span="8" :class="$style.searchbutton"> <div class="reportbuttonContent" style="margin-right: 15%"> <a-button @click="handleReset">重置</a-button> <a-button type="primary" @click="advSJBGSearch">查询</a-button> <a-button type="primary" @click="exportData">导出</a-button> </div> </a-col> </a-row> </a-form-model> </a-card> <!-- 数据表格区域 --> <a-card class="reporttablecardxm"> <sd-data-table ref="SJBGDataTable" :columns="columns" :filter-expressions="expressions" data-url="api/xcoa-mobile/v1/audit-fact-confirm/searchList" > </sd-data-table> </a-card> </a-card> </template> <script> import iamAuditWorkMixins from '@product/iam/audit/work/iam-audit-work-mixins' import axios from '@/common/services/axios-instance' import { getUserInfo } from '@/common/store-mixin' import auditAdvancedQuery from '../../components/audit-advanced-query.vue' import AuditGroupPicker from '../../components/picker/audit-group-picker.vue' import auditAdvancedQueryMixins from '../../components/audit-advanced-query-mixins' import components from './_import-components/audit-statistics-confirm--list-import' import StatisticsService from './statistics-service' import AuditRangePicker from '@product/iam/components/picker/audit-range-picker.vue' import download from '@/common/services/download' import TableActionTypes from '@/common/services/table-action-types' import moment from 'moment' export default { name: 'AuditStatisticsConfirmList', metaInfo: { title: '事实确认查询', }, components: { AuditRangePicker, auditAdvancedQuery, AuditGroupPicker, ...components, }, mixins: [auditAdvancedQueryMixins, iamAuditWorkMixins], data() { return { rootNode: {}, currentYear: new Date().getFullYear(), projectId: this.$route.query.projectId, activeKey: '1', expressions: [], auditTypeOptions: [], formItemLayout: { labelCol: { span: 6 }, wrapperCol: { span: 14 }, }, rules: { timeRange: [{ required: true, message: '请选择统计时间', trigger: 'change' }], unitNames: [{ required: true, message: '请选择审计机构', trigger: 'change' }], }, factConfirmAdvSearchForm: { timeRange: [moment(), moment()], dateStart: '', dateEnd: '', auditedUnitIds: '', unitIds: '', auditedUnitNames: [], unitNames: [], problemName: '', projectName: '', problemType: '', riskLevel: '', isAccountability: '', isNewproblems: [], problemSource: [], feedbackStatus: [], projectSourceType: '', }, riskLevelOption: [], problemTypeOption: [], isAccountabilityOption: [], projectSourceOptions: [ { text: '内部审计项目', id: '1' }, { text: '外部审计项目', id: '2' } ], columns: [ { title: '序号', customRender: (text, record, index) => `${index + 1}`, width: '80px', }, { title: '项目名称', dataIndex: 'projectname', width: '200px', }, { title: '问题名称', dataIndex: 'problemname', scopedSlots: { customRender: 'islink' }, }, { title: '业务类型', dataIndex: 'problemtype', }, { title: '风险等级', dataIndex: 'risklevel', }, { title: '问题来源', dataIndex: 'problemsource', }, { title: '新老问题', dataIndex: 'isnewproblems', }, { title: '问题描述', dataIndex: 'problemdesc', }, { title: '被审计部门反馈意见', dataIndex: 'feedbackopinion', }, { title: '问题原因', dataIndex: 'problemreason', width: '200px', }, { title: '问题整改措施', dataIndex: 'measure', width: '200px', }, { title: '问题涉及部门', dataIndex: 'involveddepartmentnames', }, { title: '问题涉及联系人', dataIndex: 'involvedcontactsnames', }, { title: '问题确认状态', dataIndex: 'feedbackstatus', }, ], actions: [ { label: '导出', id: 'export', type: TableActionTypes.primary, permission: null, callback: () => { this.exportData() }, }, ], itemStatusOptions: [], auditModeOptions: [], changeTypeOptions: [], showOpinionModal: false, problemSourceOption: [], feedbackStatusOption: [ { id: '未确认', name: '未确认' }, { id: '已确认', name: '已确认' }, ], isNewproblemsOption: [], pending: [], batchSubmitSucceed: [], batchsubmitFailed: [], } }, created() { let userInfo = getUserInfo() const params = { orgId: userInfo.deptId, } axios({ url: 'api/xcoa-mobile/v1/iamorg/getCurrentUserGroup', method: 'get', }).then((res) => { userInfo = res.data params.orgId = res.data.id axios({ url: 'api/xcoa-mobile/v1/iamorg/findIamOrgId', method: 'post', params, }).then((res) => { this.id = res.data const deptCode = userInfo.id.toString() const deptName = userInfo.name this.rootNode = { code: deptCode, name: deptName, id: this.id } }) }) }, mounted() { StatisticsService.getDictionary('GY_PROBLEM_TYPE').then((res) => { this.riskLevelOption = res.data }) StatisticsService.getDictionary('GY_PROBLEM_SOURCE').then((res) => { this.problemSourceOption = res.data }) StatisticsService.getDictionary('GY_NEW_PROBLEM').then((res) => { this.isNewproblemsOption = res.data }) this.$nextTick(() => { if (this.$refs.rangePicker) { this.$refs.rangePicker.value = this.factConfirmAdvSearchForm.timeRange } }) }, methods: { getSelectIdValue(selectValue) { if (!selectValue) return null; if (Array.isArray(selectValue) && selectValue.length > 0 && selectValue[0].id) { return selectValue[0].id; } if (typeof selectValue === 'object' && selectValue.id) { return selectValue.id; } return null; }, // 重置 handleReset() { this.factConfirmAdvSearchForm = { timeRange: [], dateStart: '', dateEnd: '', auditedUnitIds: '', unitIds: '', auditedUnitNames: [], unitNames: [], problemName: '', projectName: '', problemType: '', riskLevel: '', isAccountability: '', isNewproblems: [], problemSource: [], feedbackStatus: [], projectSourceType: '', } this.$refs.searchForm.resetFields(); }, // 导出数据 exportData() { this.$refs.searchForm.validate((valid) => { if (valid) { this.advSJBGSearch() const url = `api/xcoa-mobile/v1/audit-fact-confirm/export` const fname = '事实确认列表.xls' download({ url, method: 'post', data: { expressions: this.expressions, maxResults: -1 } }, fname) } }) }, // 查看当前登录人是否项目成员 inProjectUser(userList) { return userList.some(item => item.userAccount === getUserInfo().account); }, // 刷新列表 refresh() { this.$refs.SJBGDataTable.refresh() }, // 查询方法 advSJBGSearch() { this.$refs.searchForm.validate((valid) => { if (valid) { this.expressions = [] // 修改时间范围处理逻辑 if (this.factConfirmAdvSearchForm.timeRange && Array.isArray(this.factConfirmAdvSearchForm.timeRange) && this.factConfirmAdvSearchForm.timeRange.length >= 2) { const [startDate, endDate] = this.factConfirmAdvSearchForm.timeRange if (startDate && endDate) { this.expressions.push({ dataType: 'str', name: 'dateStart', op: 'eq', stringValue: moment(startDate).year() + '', }) this.expressions.push({ dataType: 'str', name: 'dateEnd', op: 'eq', stringValue: moment(endDate).year() + '', }) } } // 审计机构 if (this.factConfirmAdvSearchForm.unitNames) { const codes = this.factConfirmAdvSearchForm.unitNames.map(item => item.code); this.expressions.push({ dataType: 'str', name: 'unitIds', op: 'eq', stringValue: `${codes.join(',')}`, }) } // 被审计单位 if (this.factConfirmAdvSearchForm.auditedUnitNames) { const codes = this.factConfirmAdvSearchForm.auditedUnitNames.map(item => item.code); this.expressions.push({ dataType: 'str', name: 'auditedUnitIds', op: 'eq', stringValue: `${codes.join(',')}`, }) } if (this.factConfirmAdvSearchForm.problemName) { this.expressions.push({ dataType: 'str', name: 'problemName', op: 'like', stringValue: `%${this.factConfirmAdvSearchForm.problemName}%`, }) } if (this.factConfirmAdvSearchForm.projectName) { this.expressions.push({ dataType: 'str', name: 'projectName', op: 'like', stringValue: `%${this.factConfirmAdvSearchForm.projectName}%`, }) } if (this.factConfirmAdvSearchForm.problemType) { this.expressions.push({ dataType: 'str', name: 'problemType', op: 'eq', stringValue: `${this.factConfirmAdvSearchForm.problemType}`, }) } const riskLevelId = this.getSelectIdValue(this.factConfirmAdvSearchForm.riskLevel); console.log('风险等级'+riskLevelId) if (riskLevelId) { this.expressions.push({ dataType: 'str', name: 'riskLevel', op: 'eq', stringValue: riskLevelId, }) } if (this.factConfirmAdvSearchForm.isAccountability) { this.expressions.push({ dataType: 'str', name: 'isAccountability', op: 'eq', stringValue: `${this.factConfirmAdvSearchForm.isAccountability}`, }) } const isNewproblemsId = this.getSelectIdValue(this.factConfirmAdvSearchForm.isNewproblems); console.log('是否新问题'+isNewproblemsId) if (isNewproblemsId) { this.expressions.push({ dataType: 'str', name: 'isNewproblems', op: 'eq', stringValue: isNewproblemsId, }) } const problemSourceId = this.getSelectIdValue(this.factConfirmAdvSearchForm.problemSource); console.log('问题来源'+problemSourceId) if (problemSourceId) { this.expressions.push({ dataType: 'str', name: 'problemSource', op: 'eq', stringValue: problemSourceId, }) } const feedbackStatusId = this.getSelectIdValue(this.factConfirmAdvSearchForm.feedbackStatus); console.log('问题反馈状态'+problemSourceId) if (feedbackStatusId) { this.expressions.push({ dataType: 'str', name: 'feedbackStatus', op: 'eq', stringValue: feedbackStatusId, }) } // 新增项目来源筛选 if (this.factConfirmAdvSearchForm.projectSourceType) { this.expressions.push({ dataType: 'str', name: 'projectSource', op: 'eq', stringValue: `${this.factConfirmAdvSearchForm.projectSourceType}`, }) } } }) }, }, } </script> <style module lang="scss"> @use '@/common/design' as *; /* 为下拉框添加清除按钮后的样式调整 */ .select { :global { .ant-select-selection--single { padding-right: 24px; /* 为清除按钮留出空间 */ } .ant-select-arrow { right: 11px; /* 调整箭头位置 */ } } } </style> 加一个表头冻结功能
07-13
<template> <!-- 编辑流量计 --> <div class="edit-flow-meter"> <myModal :params="{ title: '编辑流量计' }" :visible="visible" @submit="submit" @cancel="handleCancel"> <template v-slot:header> <span></span> </template> <template v-slot:body> <div class="edit-flow-meter-box"> <a-form-model ref="baseInfoForm" :model="formData" :rules="rules" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" > <h4 style="margin: 16px 0; text-align: left">{{ $t('基础信息') }}</h4> <a-row> <a-col :span="12"> <a-form-model-item :label="$t('探测器名称')" prop="detectorName"> <a-input v-model="formData.detectorName" disabled /> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item :label="$t('探测器编号')" prop="uniqueCode"> <a-input v-model="formData.uniqueCode" disabled /> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item :label="$t('流量计编号')" prop="meterCode"> <a-input v-model="formData.meterCode" disabled /> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item :label="$t('接入时间')" prop="rate"> <a-input v-model.trim="formData.rate" :placeholder="$t('请输入')" :allowClear="false" /> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item :label="$t('归属')" prop="rate"> <a-input v-model="formData.uniqueCode" disabled /> </a-form-model-item> </a-col> </a-row> <div class="table-title-box"> <h4 style="margin: 0">{{ $t('子流量计列表') }}</h4> <div style="display: flex"> <a-button class="mgr10" type="primary" @click="onAdd">{{ $t('新增') }}</a-button> <a-popconfirm :title="$t('是否确认删除?')" :ok-text="$t('确定')" :cancel-text="$t('取消')" :visible="popconfirmVisible" @visibleChange="popconfirmVisibleChange" @confirm="onDeleteAll" > <a-button>{{ $t('删除') }}</a-button> </a-popconfirm> </div> <a-table :dataSource="tableData" :rowSelection="rowSelection" rowKey="id" :columns="columns" :pagination="false" size="small" > <template slot="meterCode" slot-scope="text, record, index"> <template v-if="text">{{ text }}</template> <template v-else> <a-select v-model="tableData[index].meterCode" :filterOption="filterOption" @change="changeMemterCode" :placeholder="$t('请选择')" showSearch :allowClear="false" > <a-select-option v-for="item in meterOptions" :key="item.id" :value="item.meterCode" :title="item.meterCode" :disabled="item.disabled" > {{ item.meterCode }} </a-select-option> </a-select> </template> </template> <template slot="action" slot-scope="text, record"> <a-popconfirm placement="topRight" :title="$t('是否确认删除?')" :ok-text="$t('确定')" :cancel-text="$t('取消')" @confirm="onDelete(record)" > <i class="ico-delete myIcon" :title="$t('删除')"></i> </a-popconfirm> </template> </a-table> </div> </a-form-model> </div> </template> </myModal> </div> </template> <script> import factory from '../factory'; import myModal from '@/components/scfComponents/modalComponents/modal.vue'; export default { components: { myModal }, data() { return { visible: false, formData: {}, rules: { taskName: [ { required: true, message: '请输入任务名称', trigger: 'blur' }, // { pattern: reg.name, message: this.$t('仅允许输入汉字、字母、数字与_-.@字符') }, ], }, columns: [ { title: this.$t('序号'), key: 'index', dataIndex: 'index', customRender: (text, record, index) => `${index + 1}`, }, { title: this.$t('子电表编号'), dataIndex: 'meterCode', key: 'meterCode', scopedSlots: { customRender: 'meterCode' }, }, { title: this.$t('操作'), key: 'action', width: 150, dataIndex: 'action', scopedSlots: { customRender: 'action' }, }, ], popconfirmVisible: false, meterOptions: [], selectedRowKeys: [], selectedRows: [], tableData: [], }; }, computed: { rowSelection() { return { onChange: this.rowSelectionChange, }; }, }, methods: { // 获取子电表列表 getChildMeterList(detectorCode) { let params = { detectorCodes: [detectorCode], page: 1, pageSize: 99999, }; factory.getChildMeterList(params).then(res => { if (res.success) { this.meterOptions = res.data.pageData.map(item => ({ ...item, disabled: false })) || []; } }); }, showModal() { this.getChildMeterList(record.detectorCode); this.visible = true; }, filterOption(input, option) { return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0; }, changeMemterCode(value) { let checkOption = this.meterOptions.find(el => el.meterCode === value); this.tableData.forEach(item => { if (item.meterCode === checkOption.meterCode) { item.detectorCode = checkOption.detectorCode; } }); let selectedItems = this.tableData.map(item => item.meterCode).filter(el => el !== null && el !== ''); this.meterOptions.forEach(el => { if (selectedItems.includes(el.meterCode)) { el.disabled = true; } }); }, // 全选/单选 rowSelectionChange(selectedRowKeys, selectedRows) { this.selectedRowKeys = selectedRowKeys; this.selectedRows = selectedRows; }, // 批量删除提示框 popconfirmVisibleChange(visible) { if (visible && !this.selectedRowKeys.length) { this.popconfirmVisible = false; this.$message.destroy(); this.$message.warning(this.$t('请选择要删除的信息')); } else { this.popconfirmVisible = visible; } }, // 新增 onAdd() { let isNull = this.tableData.filter(e => e.meterCode === null || e.meterCode === ''); if (isNull.length) return this.$message.warning(this.$t('请选择子电表编号')); this.tableData.push({ id: Math.random().toString().split('.')[1], meterCode: null }); }, onDeleteAll() { if (this.selectedRows.length === 0) { return this.$message.warning(this.$t('请选择子电表')); } let codes = this.selectedRows.map(item => item.id); this.tableData = this.tableData.filter(el => !codes.includes(el.id)); let selectedItems = this.selectedRows.map(item => item.meterCode).filter(el => el !== null && el !== ''); this.meterOptions.forEach(el => { if (selectedItems.includes(el.meterCode)) { el.disabled = false; } }); }, // 单个删除 onDelete(record) { this.tableData = this.tableData.filter(item => item.id !== record.id); if (record.meterCode) { this.meterOptions.forEach(el => { if (record.meterCode.indexOf(el.meterCode) !== -1) { el.disabled = false; } }); } }, submit() { this.visible = false; }, handleCancel() { this.visible = false; }, }, }; </script> <style lang="less" scoped> .edit-flow-meter-box { width: 100%; height: 100%; .table-title-box { width: 100%; display: flex; margin-bottom: 10px; align-items: center; justify-content: space-between; } }代码评审 </style>
07-08
<template> <a-card :bordered="false" :class="{isShowStyle: indirectFlag}"> <!-- 查询区域 --> <div class="table-page-search-wrapper" v-if="!indirectFlag"> <a-form layout="inline" @keyup.enter.native="searchQuery"> <a-row :gutter='24'> <a-col :span='8'> <a-form-item label='主机厂'> <a-input v-model.trim='queryParam.oems' placeholder='请输入主机厂名称'></a-input> </a-form-item> </a-col> <a-col :span='8'> <a-form-item label='客户名称'> <a-input v-model.trim='queryParam.endUser' placeholder='请输入客户名称'></a-input> </a-form-item> </a-col> <a-col :span='8'> <span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'> <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button> <a-button type='primary' @click='reset' icon='reload' style='margin-left: 8px'>重置</a-button> </span> </a-col> </a-row> </a-form> </div> <!-- 查询区域-END --> <!-- 操作按钮区域 --> <div class="table-operator"> <!-- <a-button @click="handleAdd" type="primary" icon="plus" v-if="indirectModal" :disabled="hiddenFlag">新增--> <!-- </a-button>--> <a-upload v-if="!hiddenFlag" name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel"> <a-button type="primary" icon="import" :disabled="hiddenFlag">导入</a-button> </a-upload> <!-- <a-button icon='link' type='primary' @click='outmb' v-if="indirectModal" :disabled="hiddenFlag">--> <!-- 导入模板--> <!-- </a-button>--> <a-button icon='link' type='primary' @click='outmb1' :disabled="hiddenFlag"> 导入模板 </a-button> <a-button type="primary" @click="bacthSave" v-if="indirectModal" :disabled="hiddenFlag">保存</a-button> <a-button type="primary" @click="subStatus" v-if="indirectModal" :disabled="hiddenFlag">提交</a-button> <a-dropdown v-if='selectedRowKeys.length > 0'> <a-menu slot='overlay'> <a-menu-item key='1' @click='batchDelete'> <a-icon type='delete' /> 删除 </a-menu-item> </a-menu> <a-button style='margin-left: 8px'> 批量操作 <a-icon type='down' /> </a-button> </a-dropdown> </div> <!-- table区域-begin --> <div> <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">--> <!-- <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a--> <!-- style="font-weight: 600">{{ selectedRowKeys.length }}</a>项--> <!-- <a style="margin-left: 24px" @click="onClearSelected">清空</a>--> <!-- </div>--> <j-editable-table v-if="indirectModal" ref="editableTable" size="middle" bordered rowKey="id" :columns="dynamicColumns" :dataSource="dataSource" :rowNumber="true" :pagination="ipagination" :loading="loading" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" class="j-table-force-nowrap" :actionButton="true" :disabledRows="{ status:1}" @change="handleTableChange"> <template v-slot:oemsSlot="props"> <a-input v-model='props.text' placeholder='请输入主机厂' :disabled="isDisabled(props)" @input="oemsInput(props)"> <a-icon slot='prefix' type='cluster' @click.stop='handleOemsClick(props)'/> </a-input> </template> <template v-slot:productSearchSlot="props"> <a-select v-model="props.text" show-search placeholder="请选择产品名称" :default-active-first-option="false" :show-arrow="false" :filter-option="false" :not-found-content="null" style="width: 100%" @search="handleProductSearch" @change="handleProductChange(props)" > <a-select-option v-for="item in productList" :key="item.value" :value="item.value"> {{ item.text }} </a-select-option> </a-select> </template> <template v-slot:productSlot="props"> <j-search-select-tag v-model="props.text" placeholder="请选择产品名称" dict="bs_inventory GROUP BY cInvName, cInvName, cInvName" /> </template> <template v-slot:publishSlot="props"> <div> <a-input-search v-model="props.text" placeholder="请先选择用户" readOnly unselectable="on" @search="onSearchDepUser(props)"> <a-button slot="enterButton" :disabled="false">选择用户</a-button> </a-input-search> <j-select-user-by-dep-modal ref="selectModal" modal-width="80%" :multi="false" @ok="selectOK" :user-ids="props.value" @initComp="initComp"/> </div> </template> <span slot='titleSlot' slot-scope='text'> <j-ellipsis :value='text' :length='40'/> </span> </j-editable-table> <a-table v-else ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource" :pagination="ipagination" :loading="loading" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" class="j-table-force-nowrap" @change="handleTableChange"> <span slot='titleSlot' slot-scope='text'> <j-ellipsis :value='text' :length='40'/> </span> <span slot="action" slot-scope="text, record"> <a @click="handleEdit(record)" :disabled="!record.editBtn">编辑</a> <a-divider type="vertical"/> <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)"> <a :disabled="!record.editBtn">删除</a> </a-popconfirm> </span> </a-table> </div> <indirectBusinessProducts-modal ref="modalForm" :indirectModal="indirectModal" @ok="modalFormOk"></indirectBusinessProducts-modal> <indirectBusinessProducts-item-modal ref="modalItemForm" @ok="modalFormOk"></indirectBusinessProducts-item-modal> <a-modal title='客户名称(主机厂)' :width='1000' :visible='cusVisible' @ok='handleCusSubmit' @cancel='closeCusModal' cancelText='关闭'> <cus-component ref='cusComponent'></cus-component> </a-modal> </a-card> </template> <script> import '@/assets/less/TableExpand.less' import {mixinDevice} from '@/utils/mixin' import {JeecgListMixin} from '@/mixins/JeecgListMixin' import IndirectBusinessProductsModal from './modules/IndirectBusinessProductsModal' import JEllipsis from "../../../components/jeecg/JEllipsis.vue"; import IndirectBusinessProductsItemModal from "./modules/IndirectBusinessProductsItemModal.vue"; import {deleteAction, downFile, getAction, postAction, putAction} from "../../../api/manage"; import {filterDictText, initDictOptions} from '@/components/dict/JDictSelectUtil' import {FormTypes} from '@/utils/JEditableTableUtil' import JEditableTable from "@comp/jeecg/JEditableTable.vue"; import CusComponent from "@views/modules/eoa/plan/components/CusComponent.vue"; import JSelectUserByDep from "@comp/jeecgbiz/JSelectUserByDep.vue"; import JSelectUserByDepModal from "@comp/jeecgbiz/modal/JSelectUserByDepModal.vue"; import JSearchSelectTag from "@comp/dict/JSearchSelectTag.vue"; export default { name: "IndirectBusinessProductsList", mixins: [JeecgListMixin, mixinDevice], components: { JSearchSelectTag, JSelectUserByDepModal, JSelectUserByDep, CusComponent, JEditableTable, IndirectBusinessProductsItemModal, JEllipsis, IndirectBusinessProductsModal }, props: { indirectFlag: { type: Boolean, default: false }, indirectModal: { type: Object, default: () => { } }, hiddenFlag: { type: Boolean, default: false }, }, data() { return { usernames: null, value: null, userIds: null, description: 'indirect_business_products管理页面', statusDictOptions: [], busType: 'my', cusVisible: false, // 表头 columns: [ { title: '#', dataIndex: '', key: 'rowIndex', width: 60, align: "center", customRender: function (t, r, index) { return parseInt(index) + 1; } }, // { // title: '客户名称(主机厂)', // align: "center", // dataIndex: 'oems' // }, { title: '客户名称', align: "center", dataIndex: 'endUser' }, { title: '终端用户', align: "center", dataIndex: 'oems', scopedSlots: {customRender: 'titleSlot'}, width: 100 }, { title: '车型(米)', align: "center", dataIndex: 'carType', customRender: (text, record, index) => { //字典值替换通用方法 return filterDictText(this.vehicleModelOptions, text); } }, { title: '产品明细', align: "center", scopedSlots: {customRender: 'titleSlot'}, dataIndex: 'productDetails' }, { title: '发布数量', align: "center", dataIndex: 'number' }, { title: '预测金额', align: "center", dataIndex: 'redictedAmount' }, { title: '发布人', align: "center", dataIndex: 'publishName' }, { title: '发布时间', align: "center", dataIndex: 'publishTime', customRender: function (text) { return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text) } }, { title: '产品类型', align: "center", dataIndex: 'productType', customRender: (text, record, index) => { //字典值替换通用方法 return filterDictText(this.productTypeOptions, text); } }, // { // title: '产品大类', // align: "center", // dataIndex: 'productCategories' // }, { title: '提交状态', align: "center", dataIndex: 'status', customRender: (text, record, index) => { //字典值替换通用方法 return filterDictText(this.statusDictOptions, text); } }, { title: '操作', dataIndex: 'action', align: "center", // fixed:"right", width: 147, scopedSlots: {customRender: 'action'} } ], url: { list: "/indirect_business/products/list", delete: "/indirect_business/products/delete", deleteBatch: "/indirect_business/products/deleteBatch", setStatus: "/indirect_business/products/setStatus", batchAdd: "/indirect_business/products/batchAdd", teamExcelTemplate: "indirect_business/indirectBusiness/teamExcelTemplate", teamExcelTemplateProduct: "indirect_business/indirectBusiness/teamExcelTemplateProduct", importExcelUrl: "indirect_business/products/importExcel", }, dictOptions: {}, queryParam:{ status:'1' }, productList: [],//储存产品信息列表 currentClickRowId: null, // 存储当前点击的行ID } }, computed: { importExcelUrl: function () { if (!this.indirectModal) { return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`; } else { return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}?busId=${this.indirectModal.busId}&endUser=${this.indirectModal.endCustomer}`; } }, getLoginUsername() { return this.$store.getters.userInfo.username; }, loginPermissions() { return this.indirectModal.helpPerson.includes(this.$store.getters.userInfo.username); }, rowSelection() { return { onChange: (selectedRowKeys, selectedRows) => { this.onSelectChange(selectedRowKeys, selectedRows); }, getCheckboxProps: record => ({ props: { disabled: record.status === 1 || record.status === null }, }), }; }, dynamicColumns() { const baseColumns = [ { title: "busId", align: "center", key: "busId", type: FormTypes.hidden, defaultValue: this.indirectModal.busId }, // 动态客户名称列 { title: this.indirectModal.category === '1' ? '客户名称' : '终端客户名称', align: "center", key: 'endUser', type: FormTypes.input, placeholder: '请输入客户名称', disabled: true, defaultValue: this.indirectModal.endCustomer, width: '220px' } ]; if (this.indirectModal.category === '2'){ baseColumns.push({ title: '主机厂', align: "center", key: 'oems', placeholder: "请选择主机厂", type: FormTypes.slot, slotName: 'oemsSlot', validateRules: this.indirectModal.category === '2' ? [ { required: true, message: '主机厂不能为空' }, { validator: (rule, value, callback) => { if (value === '' || value === null || value === undefined) { callback(new Error('请选择主机厂')); // 配合 required 使用 } } } ] : [], width: '220px', }); } baseColumns.push({ title: '车型(米)', align: "center", key: 'carType', type: FormTypes.select, dictCode: 'vehicle_model', placeholder: '请选择车型', customRender: (text, record, index) => { //字典值替换通用方法 return filterDictText(this.vehicleModelOptions, text); }, width: '150px' }) baseColumns.push({ title: '产品名称', align: "center", key: 'productDetails', placeholder: "请选择产品名称", type: FormTypes.slot, slotName: 'productSearchSlot', width: '240px' }) baseColumns.push({ title: '发布数量', align: "center", key: 'number', type: FormTypes.input, inputType: 'number', placeholder: "请输入发布数量", validateRules: [ { pattern: /^[1-9]\d*$/, // 正整数正则 message: '发布数量必须是正整数' } ], width: '150px' }) baseColumns.push({ title: '预测金额', align: "center", key: 'redictedAmount', type: FormTypes.input, inputType: 'number', placeholder: "请输入预测金额", // 动态校验规则(category == '2' 时必填且必须为正数) validateRules: this.indirectModal.category === '2' ? [ { required: true, message: '预测金额不能为空', trigger: ['blur', 'change'] // 触发校验的时机 }, { pattern: /^(0|[1-9]\d*)(\.\d+)?$/, // 正整数正则 message: '发布数量必须是正数' } ] : [], width: '150px' }) if (this.indirectModal.category === '2'){ baseColumns.push({ title: '主机厂负责人', align: "center", key: 'oemResponsiblePerson', type: FormTypes.hidden, }); } // if (this.indirectModal.category === '2'){ // baseColumns.push({ // title: '主机厂负责人', // align: "center", // key: 'oemResponsiblePersonName', // type: FormTypes.input, // disabled: true, // width: '200px' // }); // } baseColumns.push({ title: '发布人', align: "center", key: 'publishBy', type: FormTypes.hidden, defaultValue: this.$store.getters.userInfo.username, placeholder: "请选择发布人", width: '240px' }) baseColumns.push({ title: '发布人', align: "center", key: 'publishName', type: FormTypes.slot, slotName: 'publishSlot', defaultValue: this.$store.getters.userInfo.realname, placeholder: "请选择发布人", width: '240px' }) baseColumns.push({ title: '发布时间', align: "center", key: 'publishTime', type: FormTypes.date, customRender: function (text) { return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text) }, defaultValue: this.formatDate(new Date()), width: '170px' }) baseColumns.push({ title: '产品类型', align: "center", key: 'productType', placeholder: "请选择产品类型", type: FormTypes.select, dictCode: 'product_type', customRender: (text, record, index) => { //字典值替换通用方法 return filterDictText(this.productTypeOptions, text); }, defaultValue: '0', width: '130px' }) baseColumns.push({ title: '提交状态', align: "center", key: 'status', type: FormTypes.select, dictCode: 'public_status', customRender: (text, record, index) => { //字典值替换通用方法 return filterDictText(this.statusDictOptions, text); }, defaultValue: '0', disabled: true, width: '130px' }) return baseColumns; }, }, methods: { initDictConfig() { getAction('/base/bsInventory/distinctAllList',null).then((res) => { if (res.success) { this.productList = res.result.map(item => ({ text: item.cinvname, value: item.cinvname })) } }) //判断查询条件 if (!this.indirectModal){ this.queryParam.status = 1 this.loadData(1) }else{ this.queryParam.busId = this.indirectModal.busId this.queryParam.status = '' this.loadData(1) } console.log('this.queryParam.status',this.queryParam.status) initDictOptions('public_status').then((res) => { if (res.success) { this.statusDictOptions = res.result } }) initDictOptions('vehicle_model').then((res) => { if (res.success) { this.vehicleModelOptions = res.result } }) initDictOptions('product_type').then((res) => { if (res.success) { this.productTypeOptions = res.result } }) }, // 产品名称远程搜索 handleProductSearch(value) { if (!value) return; // 空输入不查询 // 调用接口查询匹配的产品 getAction('/base/bsInventory/distinctAllList', { 'cinvname': value }).then(res => { if (res.success) { this.productList = res.result.map(item => ({ text: item.cinvname, value: item.cinvname })); } }); }, handleProductChange(props) { // 存储当前点击的行记录和ID this.currentClickRowId = props.rowId; this.$refs.editableTable.setValues([{ rowKey: this.currentClickRowId, values: { 'productDetails': props.text } }]); }, outmb() { downFile(this.url.teamExcelTemplate, '').then((res) => { if (!res) { this.$message.warning('文件下载失败') return } let blob = new Blob([res], {type: 'application/vnd.ms-excel'}) let downloadElement = document.createElement('a') let href = window.URL.createObjectURL(blob) // 创建下载的链接 downloadElement.href = href downloadElement.download = '间接销售登记表导入模板.xls' // 下载后文件名 document.body.appendChild(downloadElement) downloadElement.click() // 点击下载 document.body.removeChild(downloadElement) // 下载完成移除元素 window.URL.revokeObjectURL(href) // 释放掉blob对象 }) }, outmb1() { downFile(this.url.teamExcelTemplateProduct, '').then((res) => { if (!res) { this.$message.warning('文件下载失败') return } let blob = new Blob([res], {type: 'application/vnd.ms-excel'}) let downloadElement = document.createElement('a') let href = window.URL.createObjectURL(blob) // 创建下载的链接 downloadElement.href = href downloadElement.download = '间接销售登记导入模板.xlsx' // 下载后文件名 document.body.appendChild(downloadElement) downloadElement.click() // 点击下载 document.body.removeChild(downloadElement) // 下载完成移除元素 window.URL.revokeObjectURL(href) // 释放掉blob对象 }) }, subStatus(){ const ids = this.$refs.editableTable.getSelection() if (ids.length==0){ this.$message.warn("请选择一条记录") return; } const selectedRow = this.$refs.editableTable.getValuesSync({rowIds: ids}).values selectedRow.forEach(item => { if (item.status == "1"){ this.$message.warn("请选择未提交的数据") return; } }) let that = this that.$confirm({ title: '提示', content: '确认提交吗?', onOk: function() { putAction(that.url.setStatus, selectedRow).then((res) => { if (res.success) { that.$message.success(res.message); that.loadData(); that.onClearSelected(); } else { that.$message.warning(res.message); that.loadData(); } }) } }) }, bacthSave() { this.$refs.editableTable.getValues(error => { if (error === 0) { let that = this postAction(that.url.batchAdd, this.$refs.editableTable.getValuesSync().values).then((res) => { if (res.success) { that.$message.success(res.message); that.loadData(); } else { that.$message.warning(res.message); that.loadData(); } }) } else { this.$message.error('验证未通过') } }) }, reset(){ this.queryParam = {status:'1'} this.loadData() }, batchDelete: function () { if(!this.url.deleteBatch){ this.$message.error("请设置url.deleteBatch属性!") return } if (this.selectedRowKeys.length <= 0) { this.$message.warning('请选择一条记录!'); return; } else if (this.selectionRows.some(item => item.status != 0)) { this.$message.warning('请选择未提交记录!') return; } else { var ids = ""; for (var a = 0; a < this.selectedRowKeys.length; a++) { ids += this.selectedRowKeys[a] + ","; } var that = this; this.$confirm({ title: "确认删除", content: "是否删除选中数据?", onOk: function () { that.loading = true; deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => { if (res.success) { that.$message.success(res.message); that.loadData(); that.onClearSelected(); } else { that.$message.warning(res.message); } }).finally(() => { that.loading = false; }); } }); } }, handleCusSubmit() { if (!this.$refs.cusComponent.selectionRows || this.$refs.cusComponent.selectionRows.length === 0) { this.$message.warning('请选择一条记录') return false } var customerNames = ""; var oemResponsiblePerson = ""; var oemResponsiblePersonName = ""; for (var a = 0; a < this.$refs.cusComponent.selectedRowRecords.length; a++) { customerNames += this.$refs.cusComponent.selectedRowRecords[a].customerName + ","; if (this.$refs.cusComponent.selectedRowRecords[a].responsiblePerson !== null) { oemResponsiblePerson += this.$refs.cusComponent.selectedRowRecords[a].responsiblePerson + ","; } if (this.$refs.cusComponent.selectedRowRecords[a].responsiblePersonName!==null){ oemResponsiblePersonName += this.$refs.cusComponent.selectedRowRecords[a].responsiblePersonName + ","; } } const oems = customerNames.substr(0,customerNames.length-1) const oemResponsiblePersons = oemResponsiblePerson.substr(0,oemResponsiblePerson.length-1) const oemResponsiblePersonNames = oemResponsiblePersonName.substr(0,oemResponsiblePersonName.length-1) // 找到当前点击的行并更新数据 this.$refs.editableTable.setValues( [{ rowKey: this.currentClickRowId, values: { 'oems': oems, 'oemResponsiblePerson': oemResponsiblePersons, 'oemResponsiblePersonName': oemResponsiblePersonNames, } }] ) this.closeCusModal() }, oemsInput(props) { // 存储当前点击的行记录和ID this.currentClickRowId = props.rowId; // 找到当前点击的行并更新数据 this.$refs.editableTable.setValues( [{ rowKey: this.currentClickRowId, values: { 'oems': props.text } }] ) }, handleOemsClick(props) { console.log("主机厂",this.$refs.editableTable.getValues({rowIds: props.rowId})) // 存储当前点击的行记录和ID this.currentClickRowId = props.rowId; this.openCusModal(); // 直接打开弹窗 }, openCusModal() { this.cusVisible = true }, closeCusModal() { this.$refs.cusComponent.selectionRows = [] this.$refs.cusComponent.selectedRowKeys = [] this.$refs.cusComponent.queryParam = {} this.cusVisible = false }, formatDate(date) { const year = date.getFullYear() const month = (date.getMonth() + 1).toString().padStart(2, '0') const day = date.getDate().toString().padStart(2, '0') return `${year}-${month}-${day}` }, initComp(userNames) { this.userNames = userNames }, onSearchDepUser(props) { this.currentClickRowId = props.rowId if (this.isSelectUser) this.$refs.selectModal.queryParam.username = this.value; this.$refs.selectModal.showModal() this.$refs.selectModal.queryParam.username = ""; }, selectOK(rows, idstr) { if (!rows) { this.userNames = '' this.userIds = '' } else { let temp = '' for (let item of rows) { temp += ',' + item.realname } this.userNames = temp.substring(1) this.userIds = idstr // 找到当前点击的行并更新数据 this.$refs.editableTable.setValues( [{ rowKey: this.currentClickRowId, values: { 'publishBy': this.userIds, 'publishName': this.userNames, } }] ) } }, // 判断是否禁用 isDisabled(props){ const item = this.$refs.editableTable.getValuesSync({rowIds: [props.rowId]}) return item.values[0].status === '1' } } } </script> <style scoped> @import '~@assets/less/common.less'; .isShowStyle /deep/ .ant-card-body { padding: unset; } </style>中<template v-slot:oemsSlot="props"> <a-input v-model='props.text' placeholder='请输入主机厂' :disabled="isDisabled(props)" @input="oemsInput(props)"> <a-icon slot='prefix' type='cluster' @click.stop='handleOemsClick(props)'/> </a-input> </template>插槽的:disabled怎么使用,我想根据本条记录的status判断是否禁用
最新发布
07-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值