2025-03-07 14:36:54 +08:00
|
|
|
<template>
|
2025-04-08 09:27:53 +08:00
|
|
|
<section class="custom-page">
|
|
|
|
<avue-crud
|
|
|
|
ref="crudRef"
|
|
|
|
v-model:search="searchCondition"
|
|
|
|
v-model:page="pageData"
|
|
|
|
:table-loading="_loading"
|
|
|
|
:option="option"
|
2025-04-09 15:49:53 +08:00
|
|
|
:data="tableData"
|
|
|
|
:before-close="(done) => (handleOtherInfo(), done())"
|
2025-04-08 09:27:53 +08:00
|
|
|
@search-change="
|
|
|
|
(form, done) => {
|
|
|
|
getData(1);
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
"
|
|
|
|
@search-reset="getData(1)"
|
|
|
|
@refresh-change="getData"
|
|
|
|
@current-change="getData"
|
|
|
|
@size-change="getData(1)"
|
|
|
|
@row-save="handleRowSave"
|
|
|
|
@row-update="handleRowUpdate"
|
|
|
|
>
|
2025-04-08 15:49:16 +08:00
|
|
|
<!-- <template #land-form="{ type }">
|
2025-04-08 09:27:53 +08:00
|
|
|
<section if="type == 'add'">地块</section>
|
2025-04-08 15:49:16 +08:00
|
|
|
</template> -->
|
2025-04-09 15:49:53 +08:00
|
|
|
<template #menu="scope">
|
|
|
|
<custom-table-operate :actions="actions" :data="scope" />
|
|
|
|
</template>
|
|
|
|
<template #report-form="{ type }">
|
2025-04-08 15:49:16 +08:00
|
|
|
<Attrs v-model:attrs="attrs" :type="type" />
|
2025-04-08 09:27:53 +08:00
|
|
|
</template>
|
2025-04-09 15:49:53 +08:00
|
|
|
<template #buyNumber-form="{ type }">
|
|
|
|
<NumberSelect v-if="type != 'view'" v-model:value="buyNumber" :options="useNumberOptions" :prop="useNumebrProp" />
|
|
|
|
<span v-else>{{ buyNumber + buyUnit }}</span>
|
|
|
|
</template>
|
|
|
|
<template #useNumber-form="{ type }">
|
|
|
|
<NumberSelect v-if="type != 'view'" v-model:value="useNumber" :options="useNumberOptions" :prop="useNumebrProp" />
|
|
|
|
<span v-else>{{ useNumber + useUnit }}</span>
|
|
|
|
</template>
|
2025-04-08 09:27:53 +08:00
|
|
|
</avue-crud>
|
|
|
|
</section>
|
2025-03-07 14:36:54 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
2025-04-09 15:49:53 +08:00
|
|
|
import { reactive, ref, onMounted } from 'vue';
|
2025-04-08 15:49:16 +08:00
|
|
|
import { CRUD_OPTIONS, pageData, customRules } from '@/config';
|
2025-04-08 09:27:53 +08:00
|
|
|
import { useBasicInfo } from '@/views/inputSuppliesManage/hooks/useBasicInfo';
|
2025-04-08 11:11:04 +08:00
|
|
|
import inputSuppliesApi from '@/apis/inputSuppliesApi';
|
|
|
|
import assistFn from '@/views/inputSuppliesManage/hooks/useAssistFn';
|
2025-04-08 15:49:16 +08:00
|
|
|
import Attrs from '@/views/inputSuppliesManage/common/Attrs.vue';
|
2025-04-09 15:49:53 +08:00
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
|
import { GetEntityList } from '@/apis/system/dict';
|
|
|
|
import NumberSelect from '@/views/inputSuppliesManage/common/NumberSelect.vue';
|
|
|
|
|
2025-04-08 11:11:04 +08:00
|
|
|
const { deleteFn } = new assistFn();
|
2025-04-09 15:49:53 +08:00
|
|
|
const { getUseSuperviseList, delUseSupervise, addUseSupervise, editUseSupervise } = inputSuppliesApi;
|
|
|
|
const { materialTypes, targetName } = useBasicInfo();
|
2025-04-08 09:27:53 +08:00
|
|
|
|
2025-04-09 15:49:53 +08:00
|
|
|
onMounted(() => {
|
|
|
|
getData();
|
|
|
|
getUseNumberDict();
|
|
|
|
});
|
|
|
|
/* --------------- tableData --------------- */
|
2025-03-07 14:36:54 +08:00
|
|
|
// #region
|
2025-04-09 15:49:53 +08:00
|
|
|
const useNumebrProp = reactive({
|
|
|
|
label: 'dictLabel',
|
|
|
|
value: 'dictValue',
|
|
|
|
});
|
|
|
|
const useNumberOptions = ref([]);
|
|
|
|
const buyNumber = ref({
|
|
|
|
num: 1,
|
|
|
|
type: '1',
|
|
|
|
});
|
|
|
|
const useNumber = ref({
|
|
|
|
num: 1,
|
|
|
|
type: '1',
|
|
|
|
});
|
2025-04-08 09:27:53 +08:00
|
|
|
const crudRef = ref(null);
|
|
|
|
const _loading = ref(true);
|
|
|
|
const searchCondition = ref({
|
|
|
|
searchType: '',
|
|
|
|
keywords: '',
|
|
|
|
});
|
|
|
|
const types = reactive([
|
|
|
|
{ label: '农药监管', value: '1' },
|
|
|
|
{ label: '肥料监管', value: '2' },
|
|
|
|
{ label: '兽药监管', value: '3' },
|
|
|
|
]);
|
2025-04-09 15:49:53 +08:00
|
|
|
const tableData = ref([{}]);
|
2025-04-08 09:27:53 +08:00
|
|
|
const option = ref({
|
|
|
|
...CRUD_OPTIONS,
|
|
|
|
selection: false,
|
|
|
|
dialogWidth: '50%',
|
|
|
|
column: [
|
|
|
|
{
|
|
|
|
hide: true,
|
|
|
|
search: true,
|
|
|
|
addDisplay: false,
|
|
|
|
editDisplay: false,
|
|
|
|
label: '物资类型',
|
|
|
|
prop: 'searchType',
|
|
|
|
type: 'select',
|
|
|
|
dicData: types,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
hide: true,
|
|
|
|
search: true,
|
|
|
|
addDisplay: false,
|
|
|
|
editDisplay: false,
|
|
|
|
label: '关键字',
|
|
|
|
prop: 'keywords',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
editDisabled: true,
|
|
|
|
label: '物资类型',
|
|
|
|
prop: 'dataType',
|
|
|
|
type: 'select',
|
|
|
|
dicData: types,
|
|
|
|
clearable: false,
|
|
|
|
value: '1',
|
|
|
|
change: handleTypeChange,
|
2025-04-09 15:49:53 +08:00
|
|
|
width: 120,
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
2025-04-09 15:49:53 +08:00
|
|
|
label: '使用者名称',
|
2025-04-08 09:27:53 +08:00
|
|
|
prop: 'name',
|
2025-04-09 15:49:53 +08:00
|
|
|
width: 240,
|
2025-04-08 15:49:16 +08:00
|
|
|
rules: customRules({ msg: '请输入名称' }),
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '联系方式',
|
|
|
|
prop: 'phone',
|
2025-04-09 15:49:53 +08:00
|
|
|
width: 120,
|
2025-04-08 15:49:16 +08:00
|
|
|
rules: customRules({ msg: '请输入联系方式' }),
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '投入品名称',
|
2025-04-08 15:49:16 +08:00
|
|
|
prop: 'inputName',
|
2025-04-09 15:49:53 +08:00
|
|
|
width: 240,
|
2025-04-08 15:49:16 +08:00
|
|
|
rules: customRules({ msg: '请输入投入品名称' }),
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
2025-04-09 15:49:53 +08:00
|
|
|
hide: true,
|
2025-04-08 09:27:53 +08:00
|
|
|
label: '分类',
|
2025-04-09 15:49:53 +08:00
|
|
|
prop: '_classifyId',
|
2025-04-08 09:27:53 +08:00
|
|
|
type: 'cascader',
|
|
|
|
dicData: [],
|
2025-04-09 15:49:53 +08:00
|
|
|
value: [],
|
2025-04-08 15:49:16 +08:00
|
|
|
rules: customRules({ msg: '请选择分类' }),
|
2025-04-09 15:49:53 +08:00
|
|
|
viewDisplay: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '分类',
|
|
|
|
prop: 'classifyName',
|
|
|
|
width: 200,
|
|
|
|
overHidden: true,
|
|
|
|
addDisplay: false,
|
|
|
|
editDisplay: false,
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '购买量',
|
2025-04-08 15:49:16 +08:00
|
|
|
prop: 'buyNumber',
|
2025-04-09 15:49:53 +08:00
|
|
|
render: ({ row }) => row.buyNumber + row.buyUnit,
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '购买时间',
|
2025-04-08 15:49:16 +08:00
|
|
|
type: 'date',
|
|
|
|
format: 'YYYY-MM-DD',
|
|
|
|
valueFormat: 'YYYY-MM-DD',
|
2025-04-09 15:49:53 +08:00
|
|
|
width: 140,
|
2025-04-08 15:49:16 +08:00
|
|
|
prop: 'buyTime',
|
|
|
|
rules: customRules({ msg: '请选择购买时间' }),
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '使用量',
|
2025-04-08 15:49:16 +08:00
|
|
|
prop: 'useNumber',
|
2025-04-09 15:49:53 +08:00
|
|
|
render: ({ row }) => row.useNumber + row.useUnit,
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '使用时间',
|
2025-04-09 15:49:53 +08:00
|
|
|
type: 'date',
|
|
|
|
width: 140,
|
2025-04-08 15:49:16 +08:00
|
|
|
format: 'YYYY-MM-DD',
|
|
|
|
valueFormat: 'YYYY-MM-DD',
|
|
|
|
prop: 'useTime',
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '使用对象',
|
2025-04-08 15:49:16 +08:00
|
|
|
prop: 'useObject',
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '关联地块',
|
2025-04-08 15:49:16 +08:00
|
|
|
prop: 'landName',
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
],
|
|
|
|
group: [
|
|
|
|
{
|
|
|
|
label: '农药检测',
|
|
|
|
prop: 'pesticide',
|
|
|
|
// addDisplay: false,
|
|
|
|
// editDisplay: false,
|
|
|
|
column: [
|
|
|
|
{
|
|
|
|
label: '检测时间',
|
2025-04-08 15:49:16 +08:00
|
|
|
prop: 'detectionTime',
|
2025-04-08 09:27:53 +08:00
|
|
|
type: 'date',
|
2025-04-09 15:49:53 +08:00
|
|
|
valueFormat: 'YYYY-MM-DD',
|
|
|
|
format: 'YYYY-MM-DD',
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '检测结果',
|
2025-04-08 15:49:16 +08:00
|
|
|
prop: 'detectionResult',
|
2025-04-09 15:49:53 +08:00
|
|
|
type: 'select',
|
|
|
|
dicData: [
|
|
|
|
{
|
|
|
|
label: '合格',
|
|
|
|
value: '0',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '不合格',
|
|
|
|
value: '1',
|
|
|
|
},
|
|
|
|
],
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '投入品名称',
|
2025-04-08 15:49:16 +08:00
|
|
|
prop: 'detectionUnit',
|
2025-04-08 09:27:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '检测报告',
|
|
|
|
prop: 'report',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
2025-04-08 15:49:16 +08:00
|
|
|
const attrs = ref([]);
|
2025-04-09 15:49:53 +08:00
|
|
|
const actions = reactive([
|
|
|
|
{
|
|
|
|
name: '详情',
|
|
|
|
icon: 'view',
|
|
|
|
event: ({ row }) => {
|
|
|
|
handleOtherInfo(row);
|
|
|
|
crudRef.value.rowView(row);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: '编辑',
|
|
|
|
icon: 'edit',
|
|
|
|
event: ({ row }) => {
|
|
|
|
handleOtherInfo(row);
|
|
|
|
crudRef.value.rowEdit(row);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'danger',
|
|
|
|
name: '删除',
|
|
|
|
icon: 'delete',
|
|
|
|
event: ({ row }) => deleteFn(row.id, delUseSupervise, getData),
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
const typeDictData = ref([]);
|
2025-03-07 14:36:54 +08:00
|
|
|
// #endregion
|
|
|
|
|
|
|
|
/* --------------- methods --------------- */
|
|
|
|
// #region
|
2025-04-09 15:49:53 +08:00
|
|
|
async function getUseNumberDict() {
|
|
|
|
let res = await GetEntityList({
|
|
|
|
dictType: 'sys_use_supervise_number',
|
|
|
|
current: 1,
|
|
|
|
size: 1000,
|
|
|
|
});
|
|
|
|
useNumberOptions.value = res?.data?.records ?? [];
|
|
|
|
if (useNumberOptions.value.length) {
|
|
|
|
buyNumber.value.type = useNumberOptions.value[0].dictValue;
|
|
|
|
useNumber.value.type = useNumberOptions.value[0].dictValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async function getData(reset = 0) {
|
2025-04-08 11:11:04 +08:00
|
|
|
_loading.value = true;
|
2025-04-09 15:49:53 +08:00
|
|
|
reset === 1 && (pageData.value.currentPage = 1);
|
2025-04-08 15:49:16 +08:00
|
|
|
let res = await getUseSuperviseList({
|
|
|
|
current: pageData.value.currentPage,
|
2025-04-08 11:11:04 +08:00
|
|
|
size: pageData.value.pageSize,
|
|
|
|
dataType: searchCondition.value.searchType,
|
|
|
|
name: searchCondition.value.keywords,
|
|
|
|
});
|
|
|
|
_loading.value = false;
|
|
|
|
if (res.code == 200) {
|
2025-04-09 15:49:53 +08:00
|
|
|
tableData.value = res.data.records.map((v) => {
|
|
|
|
return {
|
|
|
|
...v,
|
|
|
|
_classifyId: v.classifyId.split(','),
|
|
|
|
};
|
|
|
|
});
|
2025-04-08 15:49:16 +08:00
|
|
|
pageData.value.total = res.data.total;
|
2025-04-08 11:11:04 +08:00
|
|
|
}
|
2025-04-08 09:27:53 +08:00
|
|
|
}
|
|
|
|
function handleTypeChange(val) {
|
2025-04-09 15:49:53 +08:00
|
|
|
option.value.group[0].addDisplay = val.value == '1';
|
|
|
|
option.value.group[0].editDisplay = val.value == '1';
|
|
|
|
option.value.group[0].viewDisplay = val.value == '1';
|
|
|
|
typeDictData.value = materialTypes[val.value].filter((v) => v.value != '0') || [];
|
|
|
|
option.value.column[6].dicData = typeDictData.value;
|
2025-04-08 09:27:53 +08:00
|
|
|
}
|
|
|
|
function handleData(val) {
|
2025-04-09 15:49:53 +08:00
|
|
|
let _data = Object.assign({}, val);
|
|
|
|
_data.buyNumber = buyNumber.value.num;
|
|
|
|
_data.buyUnit = buyNumber.value.type;
|
|
|
|
_data.useNumber = useNumber.value.num;
|
|
|
|
_data.useUnit = useNumber.value.type;
|
|
|
|
_data.classifyId = val._classifyId.join();
|
|
|
|
_data.classifyName = targetName(typeDictData.value, val._classifyId);
|
|
|
|
if (attrs.value.length) {
|
|
|
|
_data.detectionReport = attrs.value.map((v) => v.url).join();
|
|
|
|
}
|
|
|
|
delete _data.keywords;
|
|
|
|
delete _data.searchType;
|
|
|
|
delete _data._classifyId;
|
|
|
|
return _data;
|
2025-04-08 09:27:53 +08:00
|
|
|
}
|
2025-04-09 15:49:53 +08:00
|
|
|
async function handleRowSave(row, done, loading) {
|
|
|
|
let data = handleData(row);
|
|
|
|
let res = await addUseSupervise(data);
|
|
|
|
loading();
|
|
|
|
if (res.code == 200) {
|
|
|
|
ElMessage.success('保存成功');
|
|
|
|
getData();
|
|
|
|
done();
|
|
|
|
}
|
2025-04-08 09:27:53 +08:00
|
|
|
}
|
2025-04-09 15:49:53 +08:00
|
|
|
async function handleRowUpdate(row, index, done, loading) {
|
|
|
|
let data = handleData(row);
|
|
|
|
let res = await editUseSupervise(data);
|
2025-04-08 09:27:53 +08:00
|
|
|
loading();
|
2025-04-09 15:49:53 +08:00
|
|
|
if (res.code == 200) {
|
|
|
|
ElMessage.success('保存成功');
|
|
|
|
getData();
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function handleOtherInfo(obj = {}) {
|
|
|
|
if (!Object.keys(obj).length) {
|
|
|
|
attrs.value = [];
|
|
|
|
buyNumber.value = { num: 1, type: useNumberOptions.value?.[0].dictValue ?? '1' };
|
|
|
|
useNumber.value = { num: 1, type: useNumberOptions.value?.[0].dictValue ?? '1' };
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (obj.detectionReport) {
|
|
|
|
attrs.value = obj.detectionReport.split(',').map((v, i) => {
|
|
|
|
{
|
|
|
|
return {
|
|
|
|
name: '检测报告' + i,
|
|
|
|
url: v,
|
|
|
|
uid: 'id_' + i + Date.now(),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
buyNumber.value = {
|
|
|
|
num: +obj.buyNumber,
|
|
|
|
type: obj.buyUnit,
|
|
|
|
};
|
|
|
|
useNumber.value = {
|
|
|
|
num: +obj.useNumber,
|
|
|
|
type: obj.useUnit,
|
|
|
|
};
|
2025-04-08 09:27:53 +08:00
|
|
|
}
|
2025-03-07 14:36:54 +08:00
|
|
|
// #endregion
|
|
|
|
</script>
|