商品分类下拉选择
This commit is contained in:
1 parent
75750cea2f
commit
7059d55377
4 files changed
+103
-22
No files matched your search
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<el-select
|
||||
style="width: 100%"
|
||||
v-model="state.selectId"
|
||||
:placeholder="props.placeholder"
|
||||
clearable
|
||||
remote-show-suffix
|
||||
filterable
|
||||
remote
|
||||
:remote-method="remoteSearch"
|
||||
:loading="state.loading"
|
||||
@visible-change="(e: boolean) => e && getOptions()"
|
||||
>
|
||||
<el-option v-for="v in state.options" :key="v.id" :label="`${v.name}`" :value="v.id">
|
||||
<!-- <div class="flex items-center">
|
||||
<div class="color-primary">{{ v.name }}</div>
|
||||
<div class="flex items-center just ml5">
|
||||
<el-tag size="small">
|
||||
{{ v.deptName }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div> -->
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="select-merchant">
|
||||
import { reactive, computed, defineModel, withDefaults, defineProps } from 'vue';
|
||||
import * as cocApi from '/@/api/canteen/canteenOnlineCategory';
|
||||
|
||||
const selectId = defineModel();
|
||||
|
||||
export type Props = {
|
||||
placeholder?: string;
|
||||
};
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
placeholder: '请选择',
|
||||
});
|
||||
|
||||
const queryForm = reactive<any>({
|
||||
current: 1,
|
||||
size: 10,
|
||||
});
|
||||
|
||||
const state = reactive<any>({
|
||||
loading: true,
|
||||
selectId: selectId,
|
||||
options: [],
|
||||
});
|
||||
|
||||
watch(
|
||||
selectId,
|
||||
(newVal, oldValue) => {
|
||||
if (newVal == oldValue) return;
|
||||
state.selectId = newVal;
|
||||
getOptions();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
async function getOptions() {
|
||||
try {
|
||||
state.loading = true;
|
||||
const _pa = {
|
||||
...queryForm,
|
||||
};
|
||||
const { data } = await cocApi.fetchList(_pa);
|
||||
state.options = data.records ?? [];
|
||||
} finally {
|
||||
setTimeout(() => (state.loading = false), 500);
|
||||
}
|
||||
}
|
||||
|
||||
function remoteSearch(params: string) {
|
||||
if (params != queryForm.name) {
|
||||
queryForm.name = params;
|
||||
getOptions();
|
||||
}
|
||||
}
|
||||
|
||||
function clear() {
|
||||
state.selectId = null;
|
||||
getOptions();
|
||||
}
|
||||
</script>
|
||||
+14
-13
@@ -1,7 +1,7 @@
|
||||
import Pagination from '/@/components/Pagination/index.vue';
|
||||
import RightToolbar from '/@/components/RightToolbar/index.vue';
|
||||
import DictTag from '/@/components/DictTag/index.vue';
|
||||
import DictSelect from "/@/components/DictSelect/index.vue"
|
||||
import DictSelect from '/@/components/DictSelect/index.vue';
|
||||
import UploadExcel from '/@/components/Upload/Excel.vue';
|
||||
import UploadFile from '/@/components/Upload/index.vue';
|
||||
import UploadImg from '/@/components/Upload/Image.vue';
|
||||
@@ -11,14 +11,14 @@ import Editor from '/@/components/Editor/index.vue';
|
||||
import Tip from '/@/components/Tip/index.vue';
|
||||
import TagList from '/@/components/TagList/index.vue';
|
||||
import SvgIcon from '/@/components/SvgIcon/index.vue';
|
||||
import PreviewImage from "/@/components/PreviewImage/index.vue"
|
||||
import PreviewImage from '/@/components/PreviewImage/index.vue';
|
||||
|
||||
// 业务组件
|
||||
import SelectUser from '/@/components/Select/SelectUser.vue'
|
||||
import SelectWalletType from '/@/components/Select/SelectWalletType.vue'
|
||||
import SelectMch from '/@/components/Select/SelectMch.vue'
|
||||
import SelectDept from '/@/components/Select/SelectDept.vue'
|
||||
|
||||
import SelectUser from '/@/components/Select/SelectUser.vue';
|
||||
import SelectWalletType from '/@/components/Select/SelectWalletType.vue';
|
||||
import SelectMch from '/@/components/Select/SelectMch.vue';
|
||||
import SelectDept from '/@/components/Select/SelectDept.vue';
|
||||
import SelectCtcg from '/@/components/Select/SelectCtcg.vue';
|
||||
|
||||
// 第三方组件
|
||||
import ElementPlus from 'element-plus';
|
||||
@@ -41,7 +41,7 @@ import { App } from 'vue';
|
||||
export default {
|
||||
install(app: App) {
|
||||
app.component('DictTag', DictTag);
|
||||
app.component('DictSelect', DictSelect)
|
||||
app.component('DictSelect', DictSelect);
|
||||
app.component('Pagination', Pagination);
|
||||
app.component('RightToolbar', RightToolbar);
|
||||
app.component('uploadExcel', UploadExcel);
|
||||
@@ -53,11 +53,12 @@ export default {
|
||||
app.component('DelWrap', DelWrap);
|
||||
app.component('TagList', TagList);
|
||||
app.component('SvgIcon', SvgIcon);
|
||||
app.component('PreviewImage', PreviewImage)
|
||||
app.component('SelectUser', SelectUser)
|
||||
app.component('SelectWalletType', SelectWalletType)
|
||||
app.component('SelectMch', SelectMch)
|
||||
app.component('SelectDept', SelectDept)
|
||||
app.component('PreviewImage', PreviewImage);
|
||||
app.component('SelectUser', SelectUser);
|
||||
app.component('SelectWalletType', SelectWalletType);
|
||||
app.component('SelectMch', SelectMch);
|
||||
app.component('SelectDept', SelectDept);
|
||||
app.component('SelectCtcg', SelectCtcg);
|
||||
|
||||
// 导入全部的elmenet-plus的图标
|
||||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||
|
||||
@@ -14,10 +14,7 @@
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="商品分类" prop="categoryId">
|
||||
<el-select v-model="form.categoryId" placeholder="请选择商品分类">
|
||||
<el-option label="??" :value="0" />
|
||||
<el-option label="??" :value="1" />
|
||||
</el-select>
|
||||
<select-ctcg v-model="form.categoryId" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
@@ -112,6 +109,7 @@ const form = reactive({
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
merchantId: [{ required: true, message: '商户不能为空', trigger: 'blur' }],
|
||||
categoryId: [{ required: true, message: '商品分类不能为空', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '商品名称不能为空', trigger: 'blur' }],
|
||||
picUrl: [{ required: true, message: '商品封面图不能为空', trigger: 'blur' }],
|
||||
price: [{ required: true, message: '商品价格', trigger: 'blur' }],
|
||||
|
||||
@@ -6,11 +6,8 @@
|
||||
<el-form-item label="商品名称" prop="name">
|
||||
<el-input placeholder="请输入商品名称" v-model="state.queryForm.name" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类编号" prop="categoryId">
|
||||
<el-select v-model="state.queryForm.categoryId" placeholder="请选择商品分类编号">
|
||||
<el-option label="??" :value="0" />
|
||||
<el-option label="??" :value="1" />
|
||||
</el-select>
|
||||
<el-form-item label="商品分类" prop="categoryId">
|
||||
<select-ctcg v-model="state.queryForm.categoryId" style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
|
||||
|
||||
Reference in new issue
Block a user