233 lines
5.6 KiB
Vue
Raw Normal View History

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"
:data="data"
@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> -->
<template #report-form="type">
<Attrs v-model:attrs="attrs" :type="type" />
2025-04-08 09:27:53 +08:00
</template>
</avue-crud>
</section>
2025-03-07 14:36:54 +08:00
</template>
<script setup>
2025-04-08 15:49:16 +08:00
import { reactive, ref, watch, onMounted } from 'vue';
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-08 11:11:04 +08:00
const { deleteFn } = new assistFn();
2025-04-08 15:49:16 +08:00
const { getUseSuperviseList, delUseSupdervise, addUseSupdervise, editUseSupdervise } = inputSuppliesApi;
2025-04-08 11:11:04 +08:00
const { loadFinish, materialTypes } = useBasicInfo();
2025-04-08 09:27:53 +08:00
watch(
() => loadFinish.value,
(bol) => {
if (loadFinish.value) {
console.log('material', materialTypes);
}
}
);
2025-04-08 15:49:16 +08:00
onMounted(getData);
2025-03-07 14:36:54 +08:00
/* --------------- data --------------- */
// #region
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' },
]);
const data = ref([{}]);
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-08 15:49:16 +08:00
label: '名称',
2025-04-08 09:27:53 +08:00
prop: 'name',
2025-04-08 15:49:16 +08:00
rules: customRules({ msg: '请输入名称' }),
2025-04-08 09:27:53 +08:00
},
{
label: '联系方式',
prop: 'phone',
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',
rules: customRules({ msg: '请输入投入品名称' }),
2025-04-08 09:27:53 +08:00
},
{
label: '分类',
2025-04-08 15:49:16 +08:00
prop: 'classifyId',
2025-04-08 09:27:53 +08:00
type: 'cascader',
dicData: [],
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: 'buyNumber',
rules: customRules({ msg: '请输入购买量' }),
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',
prop: 'buyTime',
rules: customRules({ msg: '请选择购买时间' }),
2025-04-08 09:27:53 +08:00
},
{
label: '使用量',
2025-04-08 15:49:16 +08:00
prop: 'useNumber',
rules: customRules({ msg: '请输入使用量' }),
2025-04-08 09:27:53 +08:00
},
{
label: '使用时间',
2025-04-08 15:49:16 +08:00
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
prop: 'useTime',
rules: customRules({ msg: '请选择使用时间' }),
2025-04-08 09:27:53 +08:00
},
{
label: '使用对象',
2025-04-08 15:49:16 +08:00
prop: 'useObject',
rules: customRules({ msg: '请输入使用对象' }),
2025-04-08 09:27:53 +08:00
},
{
label: '关联地块',
2025-04-08 15:49:16 +08:00
prop: 'landName',
rules: customRules({ msg: '请输入地块名称' }),
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',
valueFormat: 'yyyy-MM-dd',
format: 'yyyy-MM-dd',
},
{
label: '检测结果',
2025-04-08 15:49:16 +08:00
prop: 'detectionResult',
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-03-07 14:36:54 +08:00
// #endregion
/* --------------- methods --------------- */
// #region
2025-04-08 11:11:04 +08:00
async function getData(reset = 1) {
_loading.value = true;
2025-04-08 09:27:53 +08:00
reset == 1 && (pageData.value.currentPage = 1);
console.log('get data');
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-08 15:49:16 +08:00
data.value = res.data.records;
pageData.value.total = res.data.total;
2025-04-08 11:11:04 +08:00
console.log('res', res);
}
2025-04-08 09:27:53 +08:00
}
function handleTypeChange(val) {
console.log(
'dicData',
materialTypes[val.value].filter((v) => v.value != '0')
);
option.value.column[6].dicData = materialTypes[val.value].filter((v) => v.value != '0');
}
function handleData(val) {
console.log('handleData', val);
}
function handleRowSave(row, done, laoding) {
handleData(row);
laoding();
}
2025-03-07 14:36:54 +08:00
2025-04-08 09:27:53 +08:00
function handleRowUpdate(row, index, done, loading) {
handleData(row);
loading();
}
2025-03-07 14:36:54 +08:00
// #endregion
</script>
<style lang="scss" scoped></style>