This commit is contained in:
李想 2025-04-30 08:55:53 +08:00
parent 00fb3b4554
commit d11948b322
5 changed files with 75 additions and 52 deletions

View File

@ -4,6 +4,7 @@ VITE_APP_NAME = 'daimp-front-main'
VITE_APP_TITLE = '数字农业产业管理平台' VITE_APP_TITLE = '数字农业产业管理平台'
VITE_APP_SUB_OS = '//localhost:9526/sub-operation-service/' VITE_APP_SUB_OS = '//localhost:9526/sub-operation-service/'
VITE_APP_SUB_OA = '//localhost:9527/sub-operation-admin/' VITE_APP_SUB_OA = '//localhost:9527/sub-operation-admin/'
# VITE_APP_SUB_GAS = 'http://192.168.18.128:9528/sub-government-affairs-service/'
VITE_APP_SUB_GAS = '//localhost:9528/sub-government-affairs-service/' VITE_APP_SUB_GAS = '//localhost:9528/sub-government-affairs-service/'
VITE_APP_SUB_GAA = '//localhost:9525/sub-government-admin/' VITE_APP_SUB_GAA = '//localhost:9525/sub-government-admin/'
VITE_APP_SUB_GSS = '//localhost:9529/sub-government-screen-service/' VITE_APP_SUB_GSS = '//localhost:9529/sub-government-screen-service/'

View File

@ -8,13 +8,10 @@ export function getProduceList(data) {
}); });
} }
/* 新增产出品 */ /* 新增产出品 */
export function addProduceGoods(data) { export function addProduceGoods(data = {}) {
return request('/goods/business/goods/add', { return request('/goods/business/goods/add', {
method: 'POST', method: 'POST',
headers: { data: data,
'Content-Type': 'application/json',
},
data: JSON.stringify(data),
}); });
} }
@ -26,11 +23,11 @@ export function editProduceGoods(data) {
}); });
} }
/* 编辑产出品 */ /* 删除产出品 */
export function delProduceGoods(data) { export function delProduceGoods(id) {
return request('/goods/business/goods/remove', { return request(`/goods/business/goods/remove?ids=${id}`, {
method: 'POST', method: 'POST',
data, // data,
}); });
} }

View File

@ -13,12 +13,12 @@ export default {
component: () => import('@/views/produceGoods/list/index.vue'), component: () => import('@/views/produceGoods/list/index.vue'),
meta: { title: '产出品列表', icon: 'Document' }, meta: { title: '产出品列表', icon: 'Document' },
}, },
{ // {
path: '/sub-government-affairs-service/produceGoods1', // path: '/sub-government-affairs-service/produceGoods1',
name: 'produceGoods1', // name: 'produceGoods1',
component: () => import('@/views/produceGoods/test/index.vue'), // component: () => import('@/views/produceGoods/test/index.vue'),
meta: { title: '投入品监管平台', icon: 'Document' }, // meta: { title: '投入品监管平台', icon: 'Document' },
}, // },
], ],
}; };
// export default produceGoodsRoutes; // export default produceGoodsRoutes;

View File

@ -36,8 +36,8 @@
type="date" type="date"
placeholder="请选择种植日期" placeholder="请选择种植日期"
:disabled-date="disabledDate" :disabled-date="disabledDate"
format="YYYY/MM/DD" format="YYYY-MM-DD"
value-format="YYYY/MM/DD" value-format="YYYY-MM-DD"
:size="size" :size="size"
/> />
</template> </template>
@ -102,7 +102,7 @@ const state = reactive({
size: 10, size: 10,
}, },
form: {}, form: {},
selection: [], selectionRow: [],
options: { options: {
...CRUD_OPTIONS, ...CRUD_OPTIONS,
addBtn: false, addBtn: false,
@ -331,12 +331,12 @@ const refreshChange = () => {
// //
const selectionChange = (rows) => { const selectionChange = (rows) => {
state.selection = rows; state.selectionRow = rows;
console.info('selectionChange', state.selection); console.info('selectionChange', state.selectionRow);
}; };
const handleIds = () => { const handleIds = () => {
let datalist = state.selection.map((m) => { let datalist = state.selectionRow.map((m) => {
return { landId: m.landId, landName: m.landName }; return { landId: m.landId, landName: m.landName };
}); });

View File

@ -4,9 +4,9 @@
ref="crudRef" ref="crudRef"
v-model:search="searchCondition" v-model:search="searchCondition"
v-model:page="pageData" v-model:page="pageData"
:table-loading="_loading"
:data :data
:option :option
:loading="_loading"
:before-close="handleCloseDialog" :before-close="handleCloseDialog"
@search-change=" @search-change="
(form, done) => { (form, done) => {
@ -55,7 +55,7 @@ import { getLandsList } from '@/apis/land';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
// import { Download } from '@element-plus/icons-vue'; // import { Download } from '@element-plus/icons-vue';
const { getProduceList, addProduceGoods, editProduceGoods, exportProduceGoods } = produceGoodsApi; const { getProduceList, addProduceGoods, editProduceGoods, delProduceGoods, exportProduceGoods } = produceGoodsApi;
onMounted(async () => { onMounted(async () => {
await getBusiness(); await getBusiness();
await getLands(); await getLands();
@ -65,7 +65,7 @@ onMounted(async () => {
/* --------------- data --------------- */ /* --------------- data --------------- */
// #region // #region
const crudRef = ref(); const crudRef = ref();
const _loading = ref(false); const _loading = ref(true);
const searchCondition = ref({ const searchCondition = ref({
landName: '', landName: '',
quantity: null, quantity: null,
@ -85,6 +85,8 @@ const priceData = ref({
value2: '公斤', value2: '公斤',
}); });
const priceOptions = ref([]); const priceOptions = ref([]);
const lands = ref([]);
const produceMain = ref([]);
const data = ref([]); const data = ref([]);
const option = ref({ const option = ref({
...CRUD_OPTIONS, ...CRUD_OPTIONS,
@ -93,7 +95,7 @@ const option = ref({
{ {
search: true, search: true,
label: '地块名称', label: '地块名称',
prop: 'landName', prop: 'landId',
type: 'select', type: 'select',
dicData: [], dicData: [],
props: { props: {
@ -118,9 +120,13 @@ const option = ref({
], ],
}, },
{ {
label: '种植作物', label: '产品名称',
prop: 'goodsName', prop: 'goodsName',
// rules: customRules({ msg: '' }), rules: customRules({ msg: '请输入产品名称' }),
},
{
label: '产品描述',
prop: 'goodsDesc',
}, },
{ {
label: '种植面积', label: '种植面积',
@ -130,7 +136,7 @@ const option = ref({
}, },
{ {
label: '经营主体', label: '经营主体',
prop: 'producerName', prop: 'producerId',
dicData: [], dicData: [],
props: { props: {
label: 'dictLabel', label: 'dictLabel',
@ -138,6 +144,7 @@ const option = ref({
}, },
type: 'select', type: 'select',
rules: customRules({ msg: '请选择经营主体' }), rules: customRules({ msg: '请选择经营主体' }),
render: ({ row }) => row.producerName,
}, },
{ {
label: '生长周期', label: '生长周期',
@ -174,6 +181,7 @@ const option = ref({
{ {
label: '单价', label: '单价',
prop: 'marketPrice', prop: 'marketPrice',
render: ({ row }) => `${row.marketPrice}${row.priceUnit}/${row.weightUnit}`,
}, },
{ {
label: '创建时间', label: '创建时间',
@ -189,7 +197,6 @@ const actions = reactive([
name: '详情', name: '详情',
icon: 'view', icon: 'view',
event: ({ row }) => { event: ({ row }) => {
// handleCheckRegister(0);
crudRef.value.rowView(row); crudRef.value.rowView(row);
}, },
}, },
@ -197,6 +204,15 @@ const actions = reactive([
name: '编辑', name: '编辑',
icon: 'edit', icon: 'edit',
event: ({ row }) => { event: ({ row }) => {
produceNum.value = {
num: row.quantity * 1,
type: row.unit,
};
priceData.value = {
num: row.marketPrice * 1,
value1: row.priceUnit,
value2: row.weightUnit,
};
crudRef.value.rowEdit(row); crudRef.value.rowEdit(row);
}, },
}, },
@ -204,7 +220,13 @@ const actions = reactive([
type: 'danger', type: 'danger',
name: '删除', name: '删除',
icon: 'delete', icon: 'delete',
event: ({ row }) => row, event: async ({ row }) => {
let res = await delProduceGoods(row.id);
if (res.code == 200) {
ElMessage.success('删除成功');
getData();
}
},
}, },
]); ]);
// #endregion // #endregion
@ -218,7 +240,7 @@ async function getBusiness() {
size: 999, size: 999,
}); });
if (res.code == 200) { if (res.code == 200) {
option.value.column[4].dicData = res.data.records; option.value.column[5].dicData = produceMain.value = res.data.records;
} }
} }
async function getLands() { async function getLands() {
@ -227,9 +249,8 @@ async function getLands() {
size: 999, size: 999,
}); });
if (res.code == 200) { if (res.code == 200) {
option.value.column[0].dicData = res.data.records; option.value.column[0].dicData = lands.value = res.data.records;
} }
console.log('res', res);
} }
async function getPriceUnit() { async function getPriceUnit() {
let res = await GetEntityList({ dictType: 'sys_price_unit', current: 1, size: 999 }); let res = await GetEntityList({ dictType: 'sys_price_unit', current: 1, size: 999 });
@ -253,11 +274,12 @@ async function getData(resetPage) {
current: pageData.value.currentPage, current: pageData.value.currentPage,
size: pageData.value.pageSize, size: pageData.value.pageSize,
...searchCondition.value, ...searchCondition.value,
landName: searchCondition.value.landId,
}; };
let res = await getProduceList(_data); let res = await getProduceList(_data);
if (res.code == 200) { if (res.code == 200) {
data.value = res.data.records; data.value = res.data.records;
console.log('data', data.value); console.log('data', res);
pageData.value.total = res.data.total; pageData.value.total = res.data.total;
} }
_loading.value = false; _loading.value = false;
@ -266,26 +288,29 @@ function handleCloseDialog(done) {
done(); done();
} }
function handleData(val) { function handleData(val) {
let _data = Object.assign({}, val); let obj = Object.assign({}, val);
return { let _data = {
// id: _data.id, landId: obj.landId,
landName: _data.landName, producerId: obj.producerId,
producerName: _data.producerName, growthCycle: obj.growthCycle,
growthCycle: _data.growthCycle, qualityGrade: obj.qualityGrade,
qualityGrade: _data.qualityGrade, goodsName: obj.goodsName,
goodsName: _data.goodsName, goodsDesc: obj.goodsDesc,
plantingId: '0', plantingId: '0',
plantingName: 'test',
quantity: produceNum.value.num, quantity: produceNum.value.num,
unit: produceNum.value.type, unit: produceNum.value.type,
marketPrice: priceData.value.num, marketPrice: priceData.value.num,
priceUnit: priceData.value.value1, priceUnit: priceData.value.value1,
weightUnit: priceData.value.value2, weightUnit: priceData.value.value2,
}; };
_data.landName = lands.value.find((v) => v.id == obj.landId).landName;
_data.producerName = produceMain.value.find((v) => v.dictValue == obj.producerId).dictLabel;
if (obj.id) _data.id = obj.id;
return _data;
} }
async function handleRowSave(row, done, loading) { async function handleRowSave(row, done, loading) {
let _data = handleData(row); let res = await addProduceGoods(handleData(row));
console.log(_data);
let res = await addProduceGoods(_data);
loading(); loading();
if (res.code == 200) { if (res.code == 200) {
ElMessage.success('保存成功'); ElMessage.success('保存成功');
@ -294,13 +319,13 @@ async function handleRowSave(row, done, loading) {
done(); done();
} }
async function handleRowUpdate(row, index, done, loading) { async function handleRowUpdate(row, index, done, loading) {
// let data = handleData(row); let res = await editProduceGoods(handleData(row));
// let res; loading();
// loading(); console.log('res');
// if (res.code == 200) { if (res.code == 200) {
// ElMessage.success(`${basicInfo.value ? '' : ''}`); ElMessage.success(`编辑成功`);
// getData(); getData();
// } }
done(); done();
} }
// async function handleExport() { // async function handleExport() {