feat:经销商抽检完成

This commit is contained in:
李想 2025-04-10 16:58:11 +08:00
parent d195ad4826
commit a9e2ded8e4
3 changed files with 220 additions and 77 deletions

View File

@ -6,17 +6,23 @@ export function getEnterpriseDealerCheck(params) {
});
}
export function addEnterpriseDealerCheck(data) {
return request('/inputGoods/distributorCheck/page', {
return request('/inputGoods/distributorCheck/save', {
method: 'POST',
data,
});
}
export function delEnterpriseDealerCheck(ids) {
return request(`/inputGoods/distributorCheck/page/${ids}`);
return request(`/inputGoods/distributorCheck/delete/${ids}`);
}
export function editEnterpriseDealerCheck(data) {
return request('/inputGoods/distributorCheck/page', {
method: 'POST',
return request('/inputGoods/distributorCheck/edit', {
method: 'PUT',
data,
});
}
export function enterpriseDealerCheckRegister(data) {
return request('/inputGoods/distributorCheck/register', {
method: 'PUT',
data,
});
}

View File

@ -3,11 +3,13 @@
<h2>企业经销商抽检</h2>
<br />
<avue-crud
ref="crudRef"
v-model:search="searchCondition"
v-model:page="pageData"
:data="tableData"
:option="option"
:loading="_loading"
:before-close="handleCloseDialog"
@search-change="
(form, done) => {
getData(1);
@ -15,6 +17,7 @@
}
"
@search-reset="() => getData(1)"
@refresh-change="getData"
@current-change="getData"
@size-change="getData"
@row-save="handleRowSave"
@ -29,24 +32,32 @@
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { CRUD_OPTIONS, pageData } from '@/config';
import { CRUD_OPTIONS, pageData, customRules } from '@/config';
import inputSuppliesApi from '@/apis/inputSuppliesApi';
import { ElMessage } from 'element-plus';
import { add, get } from 'lodash';
const { getEnterpriseDealerCheck, addEnterpriseDealerCheck, delEnterpriseDealerCheck, editEnterpriseDealerCheck } = inputSuppliesApi;
const { getEnterpriseDealerCheck, addEnterpriseDealerCheck, delEnterpriseDealerCheck, editEnterpriseDealerCheck, enterpriseDealerCheckRegister } =
inputSuppliesApi;
onMounted(getData);
/* --------------- data --------------- */
// #region
const crudRef = ref();
const _loading = ref(false);
const searchCondition = ref({
keywords: '',
riskId: '',
});
const basicInfo = ref(true);
const tableData = ref([]);
const option = reactive({
...CRUD_OPTIONS,
selection: false,
refreshBtn: false,
updateBtnText: '确定',
addTitle: '新增巡查任务',
editTitle: '编辑巡查任务',
showOverflowTooltip: true,
column: [
{
hide: true,
@ -54,84 +65,158 @@ const option = reactive({
label: '关键字',
prop: 'keywords',
addDisplay: false,
editDisplay: false,
viewDisplay: false,
},
{
_groupKey: 'basicInfo',
_change: -1,
label: '任务编号',
prop: 'taskNum',
rules: [
{
required: true,
message: '请选择任务类型',
trigger: 'change',
},
],
prop: 'riskId',
editDisabled: true,
rules: customRules({ msg: '请输入任务编号' }),
},
{
_groupKey: 'basicInfo',
label: '创建时间',
_change: -1,
prop: 'createTime',
addDisplay: false,
editDisplay: false,
editDisabled: true,
width: 120,
},
{
_groupKey: 'basicInfo',
label: '企业名称',
prop: 'companyName',
rules: customRules({ msg: '请输入企业名称' }),
},
{
hide: true,
_groupKey: 'basicInfo',
label: '地址',
prop: 'address',
rules: customRules({ mag: '请输入地址' }),
},
{
_groupKey: 'basicInfo',
label: '企业法人',
prop: 'enterPerson',
rules: customRules({ msg: '请输入企业法人名称' }),
},
{
_groupKey: 'basicInfo',
label: '联系电话',
prop: 'phone',
width: 120,
rules: customRules({ msg: '请输入联系电话' }),
},
{
_groupKey: 'basicInfo',
label: '任务类型',
prop: 'taskType',
prop: 'riskType',
type: 'select',
clearable: false,
width: 120,
render: ({ row }) => {
return row.taskType == '0' ? '直接创建' : '民众投诉';
return row.riskType == '0' ? '直接创建' : '民众投诉';
},
value: '0',
dicData: [
{ label: '直接创建', value: '0' },
{ label: '民众投诉', value: '1' },
],
rules: [
{
required: true,
message: '请选择任务类型',
trigger: 'change',
},
],
rules: customRules({ msg: '请选择任务类型' }),
},
{
label: '企业名称',
prop: 'enterpriseName',
rules: [
{
required: true,
message: '请选择任务类型',
trigger: 'change',
},
],
},
{
label: '企业法人',
prop: 'enterpriseOwner',
rules: [
{
required: true,
message: '请选择任务类型',
trigger: 'change',
},
],
},
{
label: '联系电话',
prop: 'phone',
rules: [
{
required: true,
message: '请选择任务类型',
trigger: 'change',
},
],
hide: true,
_groupKey: 'basicInfo',
label: '投诉信息',
prop: 'complaintInfo',
span: 24,
type: 'textarea',
},
{
label: '状态',
prop: 'status',
render: ({ row }) => {
return row.status == '0' ? '未完成' : '已完成';
addDisplay: false,
editDisplay: false,
viewDisplay: false,
render: ({ row }) => (row.status == '0' ? '进行中' : '结束'),
},
rules: [
{
required: true,
message: '请选择任务类型',
trigger: 'change',
_groupKey: 'checkInfo',
hide: true,
addDisplay: false,
editDisplay: false,
label: '巡查单位',
prop: 'inspectUnit',
rules: customRules({ msg: '请输入巡查单位' }),
},
{
_groupKey: 'checkInfo',
hide: true,
addDisplay: false,
editDisplay: false,
label: '巡查部门',
prop: 'inspectDept',
rules: customRules({ msg: '请输入巡查部门' }),
},
{
_groupKey: 'checkInfo',
hide: true,
addDisplay: false,
editDisplay: false,
label: '巡查人',
prop: 'inspector',
rules: customRules({ msg: '请输入巡查人' }),
},
{
_groupKey: 'checkInfo',
hide: true,
addDisplay: false,
editDisplay: false,
label: '巡查时间',
type: 'date',
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
prop: 'inspectTime',
rules: customRules({ msg: '请输入巡查时间' }),
},
{
_groupKey: 'checkInfo',
hide: true,
addDisplay: false,
editDisplay: false,
label: '抽样产品',
prop: 'checkProducts',
rules: customRules({ msg: '请输入抽样产品' }),
},
{
_groupKey: 'checkInfo',
hide: true,
addDisplay: false,
editDisplay: false,
label: '是否违规',
type: 'select',
prop: 'isViolation',
dicData: [
{ label: '否', value: '0' },
{ label: '是', value: '1' },
],
value: '0',
rules: customRules({ msg: '请输入任务编号' }),
},
{
_groupKey: 'checkInfo',
hide: true,
addDisplay: false,
editDisplay: false,
label: '备注',
prop: 'remark',
type: 'textarea',
span: 24,
},
],
});
@ -139,12 +224,29 @@ const actions = reactive([
{
name: '详情',
icon: 'view',
event: ({ row }) => row,
event: ({ row }) => {
handleCheckRegister(0);
crudRef.value.rowView(row);
},
},
{
name: '编辑',
icon: 'edit',
event: ({ row }) => row,
event: ({ row }) => {
basicInfo.value = true;
crudRef.value.rowEdit(row);
},
},
{
auth: ({ row }) => row.status == 0,
name: '检查登记',
icon: 'check',
event: ({ row }) => {
option.editTitle = '巡查登记';
basicInfo.value = false;
handleCheckRegister(2);
crudRef.value.rowEdit(row);
},
},
{
type: 'danger',
@ -173,21 +275,56 @@ async function getData(resetPage) {
pageData.value.total = res.data.total;
}
_loading.value = false;
console.log('params', params);
pageData.value.total = tableData.value.length;
}
function handleRowSave(row, done, loading) {
console.log('row', row);
function handleData(row = {}) {
let _data = {};
let basic = ['riskId', 'enterPerson', 'companyName', 'address', 'phone', 'riskType', 'complaintInfo'];
let check = ['riskId', 'inspectUnit', 'inspectDept', 'inspector', 'inspectTime', 'isViolation', 'remark'];
(basicInfo.value ? basic : check).forEach((v) => (_data[v] = row[v] ?? null));
console.log('_data here', _data);
return _data;
}
async function handleRowSave(row, done, loading) {
let res = await addEnterpriseDealerCheck(handleData(row));
loading();
if (res.code == 200) {
ElMessage.success('保存成功');
getData();
}
done();
}
function handleRowUpdate(row, index, done, loading) {
console.log('row', row);
async function handleRowUpdate(row, index, done, loading) {
let data = handleData(row);
let res;
if (basicInfo.value) {
res = await editEnterpriseDealerCheck(data);
} else {
res = await enterpriseDealerCheckRegister(data);
}
loading();
if (res.code == 200) {
ElMessage.success(`${basicInfo.value ? '修改' : '登记'}成功`);
getData();
}
done();
}
function handleCloseDialog(done) {
basicInfo.value = true;
option.editTitle = '编辑巡查任务';
handleCheckRegister(1);
done();
}
function handleCheckRegister(t = 0) {
option.column.forEach((v) => {
if (v._groupKey == 'basicInfo') {
v.viewDisplay = t < 2 ? true : false;
v.editDisplay = t == 1;
}
if (v._groupKey == 'checkInfo') {
v.editDisplay = t == 2;
v.viewDisplay = t == 0;
}
});
}
// #endregion
</script>
<style lang="scss" scoped></style>

View File

@ -17,6 +17,7 @@
}
"
@search-reset="() => getData(1)"
@refresh-change="getData"
@current-change="getData"
@size-change="getData"
@row-save="handleRowSave"
@ -59,7 +60,6 @@ const tableData = ref([]);
const option = reactive({
...CRUD_OPTIONS,
selection: false,
refreshBtn: false,
dialogWidth: '50%',
column: [
{