xcx_temp_back/src/views/business/components/ChooseShopDialog.vue

128 lines
2.9 KiB
Vue

<template>
<el-dialog v-model="props.modelValue" title="选择店铺" width="900px" @closed="closeDialog" @open="openDialog">
<el-form inline :model="queryParams">
<el-form-item label="店铺名称">
<el-input v-model='queryParams.shopName' placeholder='请输入店铺名称'></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">
搜索
</el-button>
</el-form-item>
</el-form>
<!-- 表格渲染 prop="对应的字段"-->
<el-table v-loading="loading" :data="shopsList" ref="tableRef" border highlight-current-row
@row-click="handleRowClick">
<el-table-column prop="shopName" label="店铺名称" align="left" :show-overflow-tooltip="true" />
</el-table>
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
@pagination="getShopListFun" />
<template #footer>
<span class="dialog-footer">
<el-button type="primary" @click="handleEditClick()">添加</el-button>
<el-button @click="handleResetClick()">重置</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup>
import { reactive, ref, watch, nextTick } from 'vue';
import { ElMessage } from 'element-plus'
import { shopList } from '@/api/business/ShopManager/Shops/shop.js'
// 业务参数
const total = ref(0)
const loading = ref(false)
// 基础参数
const tableRef = ref(null);
// 查询参数
const queryParams = reactive({
shopName: "",
pageNum: 1,
pageSize: 10
});
const emits = defineEmits(['update:modelValue']);
const props = defineProps({
modelValue: Boolean,
data: Object,
done: Function,
});
const formData = ref({
...props.data
});
let shopsList = ref([]);
// 打开窗口时运行
const openDialog = async () => {
await getShopListFun()
}
/** 搜索按钮操作 */
function handleQuery() {
getShopListFun()
}
const getShopListFun = async () => {
loading.value = true
await shopList(queryParams).then((res) => {
if (res.code == 200) {
shopsList.value = res.data.result
total.value = res.data.totalNum
loading.value = false
}
})
}
watch(props, (v) => {
formData.value = v.data;
});
// -业务方法
let shopName = ref("");
let shopGuid = ref("");
// -基础方法
// 点击行
const handleRowClick = (row) => {
shopName.value = row.shopName
shopGuid.value = row.shopGuid
}
const closeDialog = () => {
queryParams.shopName = ""
shopName.value = ""
emits('update:modelValue', false);
};
// 提交
const handleEditClick = async () => {
if (shopName.value !== "") {
formData.value.shopName = shopName.value
formData.value.shopGuid = shopGuid.value
if (formData.value.shopName != null) {
if(props.done){
props.done();
}
closeDialog();
}
} else {
ElMessage.error("请选择店铺")
return;
}
};
const handleResetClick = async formEl => {
};
</script>