Merge branch 'dev' of http://192.168.18.88:8077/sznyb/daimp-front into dev
This commit is contained in:
commit
c525285857
@ -10,4 +10,4 @@ VITE_APP_SUB_GSS = '//localhost:9529/sub-government-screen-service/'
|
||||
VITE_APP_BASE_API = '/apis'
|
||||
VITE_APP_BASE_URL = 'http://192.168.18.99:8080'
|
||||
VITE_APP_UPLOAD_API = '/uploadApis'
|
||||
VITE_APP_UPLOAD_URL = 'http://192.168.18.99:9300'
|
||||
VITE_APP_UPLOAD_URL = 'http://192.168.18.99:8080'
|
@ -39,7 +39,7 @@ export default defineConfig(({ command, mode }) => {
|
||||
[VITE_APP_UPLOAD_API]: {
|
||||
target: VITE_APP_UPLOAD_URL,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/uploadApis/, ''),
|
||||
// rewrite: (path) => path.replace(/^\/uploadApis/, ''),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1,15 +1,11 @@
|
||||
import request from '@/utils/axios';
|
||||
import { isEmpty } from '@/utils';
|
||||
|
||||
/**
|
||||
* @Title: 获取字典
|
||||
*/
|
||||
export function CommonDicData(params = { pageNum: 1, pageSize: 20, dictType: null }) {
|
||||
if (isEmpty(params?.dictType)) return;
|
||||
return request(`/system/dict/data/list`, {
|
||||
export function CommonDicData(dictType) {
|
||||
return request(`/system/dict/data/type/${dictType}`, {
|
||||
method: 'GET',
|
||||
apisType: 'dicData',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -12,3 +12,10 @@ export function getPesticideList(params) {
|
||||
params,
|
||||
});
|
||||
}
|
||||
/* 新增农药 */
|
||||
export function addPesticide(data) {
|
||||
return request('/inputGoods/pesticide/save', {
|
||||
method: 'POST',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* @Author: zenghua.wang
|
||||
* @Date: 2022-02-23 21:12:37
|
||||
* @LastEditors: zenghua.wang
|
||||
* @LastEditTime: 2025-02-18 09:47:41
|
||||
* @LastEditTime: 2025-03-26 10:02:18
|
||||
*/
|
||||
import axios from 'axios';
|
||||
import { ElNotification } from 'element-plus';
|
||||
@ -51,10 +51,6 @@ publicAxios.interceptors.request.use(async (config) => {
|
||||
config.headers['Content-Type'] = config.uploadType;
|
||||
break;
|
||||
}
|
||||
case 'dicData': {
|
||||
config.baseURL = VITE_APP_DICDATA_API;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
config.baseURL = VITE_APP_BASE_API;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-menu mode="horizontal" class="input_supplies_type_menu_" @select="handleTypeSelect">
|
||||
<el-menu mode="horizontal" class="input_supplies_type_menu_" :default-active="ac" @select="handleTypeSelect">
|
||||
<template v-for="item in types" :key="`type_menu_${item.value}`">
|
||||
<el-menu-item v-if="!item.children" :index="item.value">{{ item.label }}</el-menu-item>
|
||||
<SubMenu v-else :types="item" />
|
||||
@ -8,6 +8,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import SubMenu from './SubMenu.vue';
|
||||
|
||||
const emit = defineEmits(['update:type']);
|
||||
@ -59,7 +60,12 @@ const props = defineProps({
|
||||
},
|
||||
],
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: '0',
|
||||
},
|
||||
});
|
||||
const ac = ref(props.type);
|
||||
function handleTypeSelect(key) {
|
||||
emit('update:type', key);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ export function useBasicInfo(set = {}) {
|
||||
},
|
||||
set
|
||||
);
|
||||
|
||||
/* ------ data ------ */
|
||||
// #region
|
||||
const materialTypes = reactive({
|
||||
@ -19,6 +20,7 @@ export function useBasicInfo(set = {}) {
|
||||
4: [{ value: '0', label: '全部' }],
|
||||
5: [{ value: '0', label: '全部' }],
|
||||
});
|
||||
/* 不包含顶级 */
|
||||
const materialTwoLevel = ref({});
|
||||
|
||||
/* ------ 农药 ------ */
|
||||
@ -37,19 +39,26 @@ export function useBasicInfo(set = {}) {
|
||||
// #endregion
|
||||
|
||||
// #endregion
|
||||
/* ------ ------ */
|
||||
// #region
|
||||
|
||||
/* 获取物资类型 */
|
||||
async function getmaterialType(_set = {}) {
|
||||
let params = Object.assign(searchCondition, _set);
|
||||
let res = await getMaterailTypes(params);
|
||||
console.log('two --- ', res);
|
||||
if (res && res?.code == 200) {
|
||||
res.data.forEach((item) => {
|
||||
const { moduleType, children } = item;
|
||||
materialTypes[moduleType].push(...handleTypes(children));
|
||||
// materialTwoLevel.value[moduleType] = handleTypes(children);
|
||||
handleTwoLevel();
|
||||
});
|
||||
console.log('materialTypes --- ', materialTypes);
|
||||
console.log('materialTwoLevel --- ', materialTwoLevel.value);
|
||||
}
|
||||
loadFinish.value = true;
|
||||
}
|
||||
/* 将所有的数据处理成value label格式,方便其他地方指直接使用 */
|
||||
function handleTypes(arr) {
|
||||
arr.forEach((item) => {
|
||||
item.value = item.id;
|
||||
@ -60,6 +69,7 @@ export function useBasicInfo(set = {}) {
|
||||
});
|
||||
return arr;
|
||||
}
|
||||
/* 处理二级及以下的联动数据 */
|
||||
function handleTwoLevel() {
|
||||
for (let key in materialTypes) {
|
||||
materialTwoLevel.value[key] = {};
|
||||
@ -70,6 +80,22 @@ export function useBasicInfo(set = {}) {
|
||||
});
|
||||
}
|
||||
}
|
||||
/* 获取标签的名字 */
|
||||
function targetName(arr, ids, _name) {
|
||||
let _ids = JSON.parse(JSON.stringify(ids));
|
||||
let name = '';
|
||||
if (!arr || !arr.length || _ids.length < 1) {
|
||||
return;
|
||||
} else {
|
||||
let obj = arr.find((v) => v.value == _ids[0]) || { value: '', label: '', children: [] };
|
||||
name = _name + (_name ? '/' : '') + obj.label;
|
||||
_ids.splice(0, 1);
|
||||
if (_ids.length > 0) {
|
||||
name = targetName(obj.children, _ids, name);
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
function filterTypes(_set = {}) {
|
||||
let filterType = Object.assign(
|
||||
{
|
||||
@ -81,7 +107,6 @@ export function useBasicInfo(set = {}) {
|
||||
let all = materialTypes[filterType.moduleType];
|
||||
let _arr = [];
|
||||
all.forEach((item) => {
|
||||
console.log('item', item);
|
||||
if (filterType.dataType == item.dataType) {
|
||||
_arr = item.children;
|
||||
}
|
||||
@ -89,6 +114,7 @@ export function useBasicInfo(set = {}) {
|
||||
return _arr;
|
||||
}
|
||||
|
||||
// #endregion
|
||||
onMounted(getmaterialType);
|
||||
|
||||
return {
|
||||
@ -98,6 +124,7 @@ export function useBasicInfo(set = {}) {
|
||||
goodsUnitOptions,
|
||||
useDosageUnit,
|
||||
getmaterialType,
|
||||
targetName,
|
||||
filterTypes,
|
||||
};
|
||||
}
|
||||
|
@ -37,12 +37,16 @@ const option = ref({
|
||||
CRUD_OPTIONS,
|
||||
selection: false,
|
||||
column: [
|
||||
{
|
||||
prop: 'keywords',
|
||||
label: '关键字',
|
||||
},
|
||||
{
|
||||
prop: '',
|
||||
label: '编号',
|
||||
},
|
||||
{
|
||||
prop: '',
|
||||
prop: 'xxxName',
|
||||
label: '名称',
|
||||
},
|
||||
{
|
||||
|
@ -1,16 +1,26 @@
|
||||
<template>
|
||||
<CustomCard>
|
||||
<h2>农药基本信息</h2>
|
||||
<TypeMenu v-if="materialTypes.length > 1" v-model:type="_type" :types="materialTypes['1']" />
|
||||
<TypeMenu v-if="materialTypes[1].length > 1" v-model:type="_type" :types="materialTypes['1']" />
|
||||
<br />
|
||||
<avue-crud
|
||||
ref="crud"
|
||||
v-model:page="pageData"
|
||||
v-model:search="searchCondition"
|
||||
:table-loading="_loading"
|
||||
:data="data"
|
||||
:option="option"
|
||||
:before-close="handleCloseDialog"
|
||||
@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"
|
||||
>
|
||||
@ -45,35 +55,34 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref, watch, onMounted, h, computed } from 'vue';
|
||||
import { reactive, ref, watch, onMounted, h } from 'vue';
|
||||
import CustomCard from '@/components/CustomCard.vue';
|
||||
import TypeMenu from '../../common/TypeMenu.vue';
|
||||
import { CRUD_OPTIONS } from '@/config';
|
||||
import { CRUD_OPTIONS, customRules } from '@/config';
|
||||
import { useBasicInfo } from '@/views/inputSuppliesManage/hooks/useBasicInfo';
|
||||
import Attrs from '@/views/inputSuppliesManage/common/Attrs.vue';
|
||||
import NumberSelect from '@/views/inputSuppliesManage/common/NumberSelect.vue';
|
||||
import inputSuppliesApi from '@/apis/inputSuppliesApi';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
const { loadFinish, materialTypes, materialTwoLevel, goodsUnitOptions, useDosageUnit, filterTypes } = useBasicInfo({
|
||||
const { loadFinish, materialTypes, materialTwoLevel, goodsUnitOptions, useDosageUnit, targetName, filterTypes } = useBasicInfo({
|
||||
moduleType: '1',
|
||||
});
|
||||
const { getPesticideList } = inputSuppliesApi;
|
||||
const { getPesticideList, addPesticide } = inputSuppliesApi;
|
||||
onMounted(getData);
|
||||
|
||||
/* --------------- data --------------- */
|
||||
// #region
|
||||
const _type = ref('');
|
||||
const _type = ref('0');
|
||||
watch(
|
||||
() => _type.value,
|
||||
() => {
|
||||
console.log(_type.value);
|
||||
},
|
||||
() => getData(1),
|
||||
{
|
||||
deep: true,
|
||||
}
|
||||
);
|
||||
const searchCondition = ref({
|
||||
pesticideName: '',
|
||||
keywords: '',
|
||||
});
|
||||
const crud = ref();
|
||||
const _loading = ref(false);
|
||||
@ -83,6 +92,24 @@ const pageData = ref({
|
||||
currentPage: 1,
|
||||
size: 10,
|
||||
});
|
||||
|
||||
const dicDatas = ref({
|
||||
_targetPests: {
|
||||
one: '1',
|
||||
two: '1',
|
||||
dic: [],
|
||||
},
|
||||
_mainComponent: {
|
||||
one: '1',
|
||||
two: '2',
|
||||
dic: [],
|
||||
},
|
||||
_produceDosage: {
|
||||
one: '1',
|
||||
two: '3',
|
||||
dic: [],
|
||||
},
|
||||
});
|
||||
const option = ref({
|
||||
...CRUD_OPTIONS,
|
||||
selection: false,
|
||||
@ -95,6 +122,7 @@ const option = ref({
|
||||
{
|
||||
hide: true,
|
||||
label: '关键字',
|
||||
prop: 'keywords',
|
||||
search: true,
|
||||
addDisplay: false,
|
||||
editDisplay: false,
|
||||
@ -109,6 +137,7 @@ const option = ref({
|
||||
prop: 'pesticideName',
|
||||
label: '名称',
|
||||
editDisplay: false,
|
||||
rules: customRules({ msg: '请输入农药名称' }),
|
||||
},
|
||||
{
|
||||
hide: true,
|
||||
@ -116,6 +145,7 @@ const option = ref({
|
||||
label: '产品标准证号',
|
||||
viewDisplay: false,
|
||||
editDisplay: false,
|
||||
rules: customRules({ msg: '请输入产品标准证号' }),
|
||||
},
|
||||
{
|
||||
hide: true,
|
||||
@ -129,11 +159,13 @@ const option = ref({
|
||||
label: '农药登记证号',
|
||||
viewDisplay: false,
|
||||
editDisplay: false,
|
||||
rules: customRules({ msg: '请输登记证号' }),
|
||||
},
|
||||
{
|
||||
prop: 'manufacturer',
|
||||
label: '生产厂家',
|
||||
editDisplay: false,
|
||||
rules: customRules({ msg: '请输入生产厂家' }),
|
||||
},
|
||||
{
|
||||
prop: 'distributor',
|
||||
@ -144,55 +176,80 @@ const option = ref({
|
||||
prop: 'productSpecification',
|
||||
label: '产品规格',
|
||||
editDisplay: false,
|
||||
render: ({ row }) => {
|
||||
return `${row.productSpecification}${goodsUnitOptions.find((v) => v.value == row.productUnit).label}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'toxicityLevel',
|
||||
label: '毒性',
|
||||
editDisplay: false,
|
||||
value: '无毒',
|
||||
},
|
||||
{
|
||||
prop: 'dosage',
|
||||
label: '建议用量',
|
||||
editDisplay: false,
|
||||
render: ({ row }) => {
|
||||
return `${row.suggestDosage}${useDosageUnit.find((v) => v.value == row.suggestUnit).label}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'validity',
|
||||
prop: 'expiryDate',
|
||||
label: '保质期',
|
||||
editDisplay: false,
|
||||
},
|
||||
{
|
||||
prop: 'preventTargets',
|
||||
prop: 'targetPests',
|
||||
label: '防治对象',
|
||||
type: 'cascader',
|
||||
checkStrictly: true,
|
||||
multiple: true,
|
||||
dicData: [],
|
||||
span: 24,
|
||||
editDisplay: false,
|
||||
},
|
||||
{
|
||||
prop: 'mainComponents',
|
||||
prop: 'mainComponent',
|
||||
label: '化学成分',
|
||||
type: 'cascader',
|
||||
checkStrictly: true,
|
||||
multiple: true,
|
||||
dicData: materialTwoLevel.value?.['1']?.['2'] ?? [],
|
||||
span: 24,
|
||||
editDisplay: false,
|
||||
},
|
||||
{
|
||||
prop: 'dosageForm',
|
||||
prop: 'produceDosage',
|
||||
label: '加工剂型',
|
||||
type: 'cascader',
|
||||
checkStrictly: true,
|
||||
multiple: true,
|
||||
dicData: materialTwoLevel.value?.['1']?.['3'] ?? [],
|
||||
span: 24,
|
||||
editDisplay: false,
|
||||
},
|
||||
{
|
||||
hide: true,
|
||||
prop: 'useMethods',
|
||||
prop: '_targetPests',
|
||||
label: '防治对象',
|
||||
type: 'cascader',
|
||||
multiple: true,
|
||||
dicData: [],
|
||||
value: [],
|
||||
span: 24,
|
||||
editDisplay: false,
|
||||
rules: customRules({ msg: '请选择防治对象' }),
|
||||
},
|
||||
{
|
||||
hide: true,
|
||||
prop: '_mainComponent',
|
||||
label: '化学成分',
|
||||
type: 'cascader',
|
||||
multiple: true,
|
||||
dicData: [],
|
||||
value: [],
|
||||
span: 24,
|
||||
editDisplay: false,
|
||||
rules: customRules({ msg: '请选择主要成分' }),
|
||||
},
|
||||
{
|
||||
hide: true,
|
||||
prop: '_produceDosage',
|
||||
label: '加工剂型',
|
||||
type: 'cascader',
|
||||
multiple: true,
|
||||
dicData: [],
|
||||
value: [],
|
||||
span: 24,
|
||||
editDisplay: false,
|
||||
rules: customRules({ msg: '加工剂型' }),
|
||||
},
|
||||
{
|
||||
hide: true,
|
||||
prop: 'usageMethod',
|
||||
label: '使用方法',
|
||||
type: 'textarea',
|
||||
span: 24,
|
||||
@ -201,7 +258,7 @@ const option = ref({
|
||||
},
|
||||
{
|
||||
hide: true,
|
||||
prop: 'tips',
|
||||
prop: 'precautions',
|
||||
label: '注意事项',
|
||||
type: 'textarea',
|
||||
span: 24,
|
||||
@ -287,18 +344,15 @@ watch(
|
||||
() => loadFinish.value,
|
||||
() => {
|
||||
if (loadFinish.value) {
|
||||
let newDicName = [
|
||||
{ key: '', one: '1', two: '1' },
|
||||
{ key: '', one: '1', two: '2' },
|
||||
{ key: '', one: '1', two: '3' },
|
||||
];
|
||||
newDicName.forEach((v) => {
|
||||
for (let key in dicDatas.value) {
|
||||
option.value.column.forEach((item) => {
|
||||
if (item.prop === v.key) {
|
||||
item.dicData = materialTwoLevel?.[v.one]?.[v.two] ?? [];
|
||||
if (item.prop === key) {
|
||||
let dic = materialTwoLevel.value?.[dicDatas.value[key].one]?.[dicDatas.value[key].two] ?? [];
|
||||
dicDatas.value[key].dic = dic;
|
||||
item.dicData = dic;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -323,8 +377,9 @@ async function getData(reset) {
|
||||
let params = {
|
||||
current: pageData.value.currentPage,
|
||||
size: pageData.value.size,
|
||||
...searchCondition.value,
|
||||
pesticideName: searchCondition.value.keywords,
|
||||
};
|
||||
_type.value != '0' && (params.classifyId = _type.value);
|
||||
let res = await getPesticideList(params);
|
||||
console.log('res --- ', res);
|
||||
_loading.value = false;
|
||||
@ -334,14 +389,68 @@ async function getData(reset) {
|
||||
}
|
||||
}
|
||||
function handleCloseDialog(done) {
|
||||
resetOtherInfo();
|
||||
handleCheckInfoChange();
|
||||
done();
|
||||
}
|
||||
|
||||
function handleRowSave(form, done, loading) {
|
||||
async function handleRowSave(form, done, loading) {
|
||||
console.log('handleRowSave', form);
|
||||
let data = {
|
||||
pesticideName: form.pesticideName,
|
||||
productStandCode: form.productStandCode,
|
||||
pesticideRegistCode: form.pesticideRegistCode,
|
||||
manufacturer: form.manufacturer,
|
||||
distributor: form.distributor,
|
||||
toxicityLevel: form.toxicityLevel,
|
||||
usageMethod: form.usageMethod,
|
||||
precautions: form.precautions,
|
||||
expiryDate: form.expiryDate,
|
||||
productSpecification: productSpecification.value.num,
|
||||
productUnit: productSpecification.value.type,
|
||||
suggestDosage: useDosage.value.num,
|
||||
suggestUnit: useDosage.value.type,
|
||||
};
|
||||
if (attrs.value.length) {
|
||||
data.pesticidePhoto = attrs.value.map((v) => v.url).join();
|
||||
}
|
||||
if (form._targetPests.length) {
|
||||
let names = [];
|
||||
form._targetPests.forEach((item) => {
|
||||
names.push(targetName(dicDatas.value._targetPests.dic, item, ''));
|
||||
});
|
||||
data.targetPests = JSON.stringify(form._targetPests) + '|' + JSON.stringify(names);
|
||||
}
|
||||
if (form._mainComponent.length) {
|
||||
let names = [];
|
||||
form._mainComponent.forEach((item) => {
|
||||
names.push(targetName(dicDatas.value._mainComponent.dic, item, ''));
|
||||
});
|
||||
data.mainComponent = JSON.stringify(form._mainComponent) + '|' + JSON.stringify(names);
|
||||
}
|
||||
if (form._produceDosage.length) {
|
||||
let names = [];
|
||||
form._produceDosage.forEach((item) => {
|
||||
names.push(targetName(dicDatas.value._produceDosage.dic, item, ''));
|
||||
});
|
||||
data.produceDosage = JSON.stringify(form._produceDosage) + '|' + JSON.stringify(names);
|
||||
}
|
||||
let res = await addPesticide(data);
|
||||
if (res.code == 200) {
|
||||
ElMessage.success('保存成功');
|
||||
getData();
|
||||
// resetOtherInfo();
|
||||
// done();
|
||||
}
|
||||
loading();
|
||||
}
|
||||
function resetOtherInfo() {
|
||||
let obj = { num: 1, type: '1' };
|
||||
attrs.value = [];
|
||||
productSpecification.value = obj;
|
||||
useDosage.value = obj;
|
||||
}
|
||||
|
||||
function handleEdit(row) {
|
||||
console.log('handleEdit', row);
|
||||
handleCheckInfoChange('open');
|
||||
@ -389,6 +498,11 @@ async function handleRowUpdate(form, done, loading) {
|
||||
console.log('update from -- ', form);
|
||||
loading();
|
||||
}
|
||||
function handleShowName(text = '') {
|
||||
if (!text || text.includes('|')) return false;
|
||||
let names = text.split('|')[1];
|
||||
console.log('names', names);
|
||||
}
|
||||
// #endregion
|
||||
</script>
|
||||
|
||||
|
@ -0,0 +1,449 @@
|
||||
<template>
|
||||
<div class="custom-page">
|
||||
<el-row :gutter="20">
|
||||
<splitpanes class="default-theme">
|
||||
<pane size="16">
|
||||
<el-col :span="4">
|
||||
<custom-table-tree title="种养殖基地分类" :data="treeData" :option="treeOption" @node-click="onNodeClick">
|
||||
<template #default="{ data }">
|
||||
<div :class="{ 'text-primary': data.dictValue == treeSelected.dictValue }">
|
||||
{{ data.dictLabel }}
|
||||
</div>
|
||||
</template>
|
||||
</custom-table-tree>
|
||||
</el-col>
|
||||
</pane>
|
||||
<pane size="84">
|
||||
<el-col>
|
||||
<avue-crud
|
||||
ref="crudRef"
|
||||
v-model="state.form"
|
||||
v-model:search="state.query"
|
||||
v-model:page="state.pageData"
|
||||
:table-loading="state.loading"
|
||||
:data="state.data"
|
||||
:option="state.options"
|
||||
@refresh-change="refreshChange"
|
||||
@search-reset="searchChange"
|
||||
@search-change="searchChange"
|
||||
@selection-change="selectionChange"
|
||||
@current-change="currentChange"
|
||||
@size-change="sizeChange"
|
||||
@row-del="rowDel"
|
||||
@row-save="rowSave"
|
||||
@row-update="rowUpdate"
|
||||
>
|
||||
<template #menu-left>
|
||||
<el-button type="danger" icon="delete" @click="onDel(state.selection)">批量删除</el-button>
|
||||
</template>
|
||||
|
||||
<template #status="{ row }">
|
||||
<el-tag v-if="row.status == 1" type="success" size="small">启用</el-tag>
|
||||
<el-tag v-if="row.status == 0" type="danger" size="small">禁用</el-tag>
|
||||
</template>
|
||||
|
||||
<template #menu="scope">
|
||||
<custom-table-operate :actions="state.options.actions" :data="scope" />
|
||||
</template>
|
||||
</avue-crud>
|
||||
</el-col>
|
||||
</pane>
|
||||
</splitpanes>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useApp } from '@/hooks';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { CRUD_OPTIONS } from '@/config';
|
||||
import { isEmpty, mockData, sleep, setDicData } from '@/utils';
|
||||
import { CommonDicData } from '@/apis';
|
||||
import { getLandsList } from '@/apis/land';
|
||||
|
||||
const { VITE_APP_BASE_API } = import.meta.env;
|
||||
const app = useApp();
|
||||
const UserStore = useUserStore();
|
||||
const router = useRouter();
|
||||
const crudRef = ref(null);
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
query: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
},
|
||||
form: {},
|
||||
selection: [],
|
||||
options: {
|
||||
...CRUD_OPTIONS,
|
||||
selection: true,
|
||||
column: [
|
||||
{
|
||||
label: '基地名称',
|
||||
prop: 'p1',
|
||||
search: true,
|
||||
width: 200,
|
||||
rules: {
|
||||
required: true,
|
||||
message: '请输入',
|
||||
trigger: 'blur',
|
||||
},
|
||||
overHidden: true,
|
||||
},
|
||||
{
|
||||
label: '基地分类',
|
||||
prop: 'type',
|
||||
type: 'select',
|
||||
props: {
|
||||
label: 'landName',
|
||||
value: 'id',
|
||||
},
|
||||
dicUrl: `${VITE_APP_BASE_API}/land-resource/landManage/page?current=1&size=20`,
|
||||
dicHeaders: {
|
||||
authorization: UserStore.token,
|
||||
},
|
||||
dicFormatter: (res) => res.data?.records ?? [],
|
||||
rules: {
|
||||
required: true,
|
||||
message: '请输入',
|
||||
trigger: 'blur',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '地块名',
|
||||
prop: 'landName',
|
||||
width: 200,
|
||||
type: 'select',
|
||||
props: {
|
||||
label: 'landName',
|
||||
value: 'id',
|
||||
},
|
||||
dicUrl: `${VITE_APP_BASE_API}/land-resource/landManage/page?current=1&size=20`,
|
||||
dicHeaders: {
|
||||
authorization: UserStore.token,
|
||||
},
|
||||
dicFormatter: (res) => res.data?.records ?? [],
|
||||
filterable: true,
|
||||
remote: true,
|
||||
clearable: true,
|
||||
remoteMethod: (val) => remoteLandList(val),
|
||||
change: (val) => selectedChange(val),
|
||||
rules: {
|
||||
required: true,
|
||||
message: '请选择',
|
||||
trigger: 'blur',
|
||||
},
|
||||
// addDisplay: true,
|
||||
// editDisplay: true,
|
||||
// viewDisplay: false,
|
||||
// overHidden: true,
|
||||
},
|
||||
{
|
||||
label: '区域位置',
|
||||
prop: 'p3',
|
||||
width: 200,
|
||||
overHidden: true,
|
||||
rules: {
|
||||
required: true,
|
||||
message: '请输入',
|
||||
trigger: 'blur',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '区域面积',
|
||||
prop: 'p4',
|
||||
rules: {
|
||||
required: true,
|
||||
message: '请输入',
|
||||
trigger: 'blur',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
prop: 'status',
|
||||
type: 'select',
|
||||
dicData: [
|
||||
{
|
||||
label: '启用',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: '禁用',
|
||||
value: 0,
|
||||
},
|
||||
],
|
||||
rules: {
|
||||
required: true,
|
||||
message: '请输入',
|
||||
trigger: 'blur',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '负责人',
|
||||
prop: 'p5',
|
||||
rules: {
|
||||
required: true,
|
||||
message: '请输入',
|
||||
trigger: 'blur',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '联系电话',
|
||||
prop: 'p6',
|
||||
width: 150,
|
||||
rules: {
|
||||
required: true,
|
||||
message: '请输入',
|
||||
trigger: 'blur',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
prop: 'createTime',
|
||||
width: 150,
|
||||
// search: true,
|
||||
display: false,
|
||||
},
|
||||
{
|
||||
label: '更新时间',
|
||||
prop: 'updateTime',
|
||||
width: 150,
|
||||
display: false,
|
||||
},
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
name: '查看',
|
||||
icon: 'view',
|
||||
event: ({ row }) => rowView(row),
|
||||
},
|
||||
{
|
||||
name: '编辑',
|
||||
icon: 'edit',
|
||||
event: ({ row }) => rowEdit(row),
|
||||
},
|
||||
// {
|
||||
// type: 'success',
|
||||
// name: ({ row }) => {
|
||||
// return row.status === 1 ? '禁用' : '启用';
|
||||
// },
|
||||
// icon: ({ row }) => {
|
||||
// return row.status === 1 ? 'turnOff' : 'open';
|
||||
// },
|
||||
// event: ({ row }) => rowStatus(row),
|
||||
// },
|
||||
{
|
||||
type: 'danger',
|
||||
name: '删除',
|
||||
icon: 'delete',
|
||||
event: ({ row }) => rowDel(row),
|
||||
},
|
||||
],
|
||||
},
|
||||
pageData: {
|
||||
total: 0,
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
data: [],
|
||||
currentRow: {},
|
||||
});
|
||||
|
||||
// tree
|
||||
const treeData = ref([]);
|
||||
const treeOption = ref({
|
||||
nodeKey: 'id',
|
||||
props: { label: 'dictLabel', id: 'dictValue' },
|
||||
});
|
||||
const treeSelected = ref({});
|
||||
const getTree = async () => {
|
||||
try {
|
||||
const res = await CommonDicData({ dictType: 'sys_base_type' });
|
||||
if (res.code == 200) {
|
||||
treeData.value = res.data.records;
|
||||
}
|
||||
} catch (err) {
|
||||
app.$message.error(err.msg);
|
||||
}
|
||||
};
|
||||
getTree();
|
||||
|
||||
// 加载
|
||||
const loadData = async () => {
|
||||
//state.loading = true;
|
||||
// GetEntityList(state.query)
|
||||
// .then((res) => {
|
||||
// if (res.code === 200) {
|
||||
// const { current, size, total, records } = res.data;
|
||||
// state.data = records;
|
||||
// state.pageData = {
|
||||
// currentPage: current || 1,
|
||||
// pageSize: size || 10,
|
||||
// total: total,
|
||||
// };
|
||||
// }
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// app.$message.error(err.msg);
|
||||
// state.data = [];
|
||||
// })
|
||||
// .finally(() => {
|
||||
// state.loading = false;
|
||||
// });
|
||||
|
||||
state.loading = true;
|
||||
await sleep(500);
|
||||
state.data = mockData(
|
||||
{
|
||||
p1: '耿马镇一号基地',
|
||||
landName: '耿马镇2025001号地块',
|
||||
p3: '耿马傣族佤族自治县/耿马镇',
|
||||
p4: '1000',
|
||||
p5: '张三',
|
||||
p6: '13837633838',
|
||||
status: 1,
|
||||
type: 1,
|
||||
createTime: '2025-01-01',
|
||||
updateTime: '2025-01-15',
|
||||
},
|
||||
10
|
||||
);
|
||||
state.loading = false;
|
||||
};
|
||||
|
||||
loadData();
|
||||
|
||||
const onNodeClick = (data) => {
|
||||
console.log(300, data);
|
||||
treeSelected.value = data;
|
||||
};
|
||||
|
||||
// 页数
|
||||
const currentChange = (current) => {
|
||||
state.query.current = current;
|
||||
loadData();
|
||||
};
|
||||
|
||||
// 条数
|
||||
const sizeChange = (size) => {
|
||||
state.query.size = size;
|
||||
loadData();
|
||||
};
|
||||
|
||||
// 搜索
|
||||
const searchChange = (params, done) => {
|
||||
if (done) done();
|
||||
state.query = params;
|
||||
state.query.current = 1;
|
||||
loadData();
|
||||
};
|
||||
|
||||
// 刷新
|
||||
const refreshChange = () => {
|
||||
loadData();
|
||||
app.$message.success('刷新成功');
|
||||
};
|
||||
|
||||
// 选择
|
||||
const selectionChange = (rows) => {
|
||||
state.selection = rows;
|
||||
};
|
||||
|
||||
// 查看
|
||||
const rowView = (row) => {
|
||||
crudRef.value.rowView(row);
|
||||
};
|
||||
|
||||
// 启用、禁用
|
||||
// const rowStatus = (row) => {
|
||||
// console.info('操作状态');
|
||||
// };
|
||||
|
||||
// 新增
|
||||
// const onAdd = () => {
|
||||
// crudRef.value && crudRef.value.rowAdd();
|
||||
// };
|
||||
const rowSave = (row, done, loading) => {
|
||||
// AddEntity(row)
|
||||
// .then((res) => {
|
||||
// if (res.code === 200) {
|
||||
// app.$message.success('添加成功!');
|
||||
// done();
|
||||
// loadData();
|
||||
// }
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// app.$message.error(err.msg);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// loading();
|
||||
// });
|
||||
};
|
||||
|
||||
// 编辑
|
||||
const rowEdit = (row) => {
|
||||
crudRef.value && crudRef.value.rowEdit(row);
|
||||
};
|
||||
|
||||
const rowUpdate = (row, index, done, loading) => {
|
||||
// UpdateEntity(row)
|
||||
// .then((res) => {
|
||||
// if (res.code === 200) {
|
||||
// app.$message.success('更新成功!');
|
||||
// done();
|
||||
// loadData();
|
||||
// }
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// app.$message.error(err.msg);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// loading();
|
||||
// });
|
||||
};
|
||||
|
||||
// 删除
|
||||
const onDel = (rows = []) => {
|
||||
if (isEmpty(rows)) return;
|
||||
const ids = rows.map((item) => item.id);
|
||||
app
|
||||
.$confirm(`删除后信息将不可查看,确认要删除吗?`, '确定删除', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
// DeleteEntity({ ids: ids.join(',') })
|
||||
// .then((res) => {
|
||||
// if (res.code === 200) {
|
||||
// app.$message.success('删除成功!');
|
||||
// loadData();
|
||||
// }
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// app.$message.error(err.msg);
|
||||
// });
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const rowDel = (row, index, done) => {
|
||||
onDel([row]);
|
||||
};
|
||||
|
||||
// 远程搜搜
|
||||
const remoteLandList = async (val) => {
|
||||
if (isEmpty(val)) return;
|
||||
const query = { landName: val, current: 1, size: 20 };
|
||||
const res = await getLandsList(query);
|
||||
if (res.code === 200) {
|
||||
setDicData(state.options.column, 'landName', res.data.records);
|
||||
}
|
||||
};
|
||||
|
||||
// 选择赋值
|
||||
const selectedChange = ({ value, item }) => {
|
||||
console.log(430, value, item, item.landName, item.address, item.area);
|
||||
};
|
||||
</script>
|
@ -1,10 +1,5 @@
|
||||
<template>
|
||||
<div class="custom-page">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="4">
|
||||
<custom-table-tree title="种养殖基地分类" :data="treeData" @node-click="onNodeClick" />
|
||||
</el-col>
|
||||
<el-col :span="20">
|
||||
<avue-crud
|
||||
ref="crudRef"
|
||||
v-model="state.form"
|
||||
@ -36,8 +31,6 @@
|
||||
<custom-table-operate :actions="state.options.actions" :data="scope" />
|
||||
</template>
|
||||
</avue-crud>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
@ -49,21 +42,11 @@ import { CRUD_OPTIONS } from '@/config';
|
||||
import { isEmpty, mockData, sleep, setDicData } from '@/utils';
|
||||
import { getLandsList } from '@/apis/land';
|
||||
|
||||
const { VITE_APP_BASE_API, VITE_APP_NAME } = import.meta.env;
|
||||
const { VITE_APP_BASE_API } = import.meta.env;
|
||||
const app = useApp();
|
||||
const UserStore = useUserStore();
|
||||
const router = useRouter();
|
||||
const crudRef = ref(null);
|
||||
const treeData = ref([
|
||||
{
|
||||
label: '基地分类',
|
||||
id: null,
|
||||
children: [
|
||||
{ label: '种植基地', id: '1', children: [], pid: null },
|
||||
{ label: '养殖基地', id: '2', children: [], pid: null },
|
||||
],
|
||||
},
|
||||
]);
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
query: {
|
||||
@ -74,8 +57,6 @@ const state = reactive({
|
||||
selection: [],
|
||||
options: {
|
||||
...CRUD_OPTIONS,
|
||||
addBtnText: '添加',
|
||||
// addBtn: false,
|
||||
selection: true,
|
||||
column: [
|
||||
{
|
||||
@ -94,16 +75,16 @@ const state = reactive({
|
||||
label: '基地分类',
|
||||
prop: 'type',
|
||||
type: 'select',
|
||||
dicData: [
|
||||
{
|
||||
label: '种植基地',
|
||||
value: 1,
|
||||
search: true,
|
||||
props: {
|
||||
label: 'dictLabel',
|
||||
value: 'dictValue',
|
||||
},
|
||||
{
|
||||
label: '养殖基地',
|
||||
value: 2,
|
||||
dicUrl: `${VITE_APP_BASE_API}/system/dict/data/type/sys_base_type`,
|
||||
dicHeaders: {
|
||||
authorization: UserStore.token,
|
||||
},
|
||||
],
|
||||
dicFormatter: (res) => res.data ?? [],
|
||||
rules: {
|
||||
required: true,
|
||||
message: '请输入',
|
||||
@ -250,6 +231,7 @@ const state = reactive({
|
||||
currentRow: {},
|
||||
});
|
||||
|
||||
// 加载
|
||||
const loadData = async () => {
|
||||
//state.loading = true;
|
||||
// GetEntityList(state.query)
|
||||
@ -283,7 +265,7 @@ const loadData = async () => {
|
||||
p5: '张三',
|
||||
p6: '13837633838',
|
||||
status: 1,
|
||||
type: 1,
|
||||
type: 'base_plant',
|
||||
createTime: '2025-01-01',
|
||||
updateTime: '2025-01-15',
|
||||
},
|
||||
@ -294,10 +276,6 @@ const loadData = async () => {
|
||||
|
||||
loadData();
|
||||
|
||||
const onNodeClick = (data) => {
|
||||
console.log('onNodeClick', data);
|
||||
};
|
||||
|
||||
// 页数
|
||||
const currentChange = (current) => {
|
||||
state.query.current = current;
|
||||
@ -335,15 +313,14 @@ const rowView = (row) => {
|
||||
};
|
||||
|
||||
// 启用、禁用
|
||||
const rowStatus = (row) => {
|
||||
console.info('操作状态');
|
||||
};
|
||||
// const rowStatus = (row) => {
|
||||
// console.info('操作状态');
|
||||
// };
|
||||
|
||||
// 新增
|
||||
const onAdd = () => {
|
||||
crudRef.value && crudRef.value.rowAdd();
|
||||
};
|
||||
|
||||
// const onAdd = () => {
|
||||
// crudRef.value && crudRef.value.rowAdd();
|
||||
// };
|
||||
const rowSave = (row, done, loading) => {
|
||||
// AddEntity(row)
|
||||
// .then((res) => {
|
||||
|
@ -123,7 +123,7 @@ const state = reactive({
|
||||
label: 'dictLabel',
|
||||
value: 'dictValue',
|
||||
},
|
||||
dicUrl: `${VITE_APP_BASE_API}/system/dict/data/list?pageNum=1&pageSize=20&dictType=sys_product_type`,
|
||||
dicUrl: `${VITE_APP_BASE_API}/system/dict/data/type/sys_product_type`,
|
||||
dicHeaders: {
|
||||
authorization: UserStore.token,
|
||||
},
|
||||
@ -152,7 +152,7 @@ const state = reactive({
|
||||
label: 'dictLabel',
|
||||
value: 'dictValue',
|
||||
},
|
||||
dicUrl: `${VITE_APP_BASE_API}/system/dict/data/list?pageNum=1&pageSize=20&dictType=sys_unit_type`,
|
||||
dicUrl: `${VITE_APP_BASE_API}/system/dict/data/type/sys_unit_type`,
|
||||
dicHeaders: {
|
||||
authorization: UserStore.token,
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user