This commit is contained in:
13713575202 2025-04-30 08:57:37 +08:00
commit 5631378b5b
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_SUB_OS = '//localhost:9526/sub-operation-service/'
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_GAA = '//localhost:9525/sub-government-admin/'
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', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: JSON.stringify(data),
data: data,
});
}
@ -26,11 +23,11 @@ export function editProduceGoods(data) {
});
}
/* 编辑产出品 */
export function delProduceGoods(data) {
return request('/goods/business/goods/remove', {
/* 删除产出品 */
export function delProduceGoods(id) {
return request(`/goods/business/goods/remove?ids=${id}`, {
method: 'POST',
data,
// data,
});
}

View File

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

View File

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

View File

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