From 1389a6dbadac9cd80441abdd29c13be929812f0d Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Tue, 22 Sep 2026 09:53:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/customer/component/addOrder.vue | 2 +- src/views/order/component/addOrder.vue | 76 ++++++++++++++++------- src/views/order/order.vue | 2 +- vue.config.js | 2 +- 4 files changed, 58 insertions(+), 24 deletions(-) diff --git a/src/views/customer/component/addOrder.vue b/src/views/customer/component/addOrder.vue index 2349ac1..3067164 100644 --- a/src/views/customer/component/addOrder.vue +++ b/src/views/customer/component/addOrder.vue @@ -212,7 +212,7 @@ export default { products: [], productSelect: { page: 1, - page_size: 10 + page_size: 999 }, pickedProduct:{}, ageTemp:false, diff --git a/src/views/order/component/addOrder.vue b/src/views/order/component/addOrder.vue index a9a3312..e33008e 100644 --- a/src/views/order/component/addOrder.vue +++ b/src/views/order/component/addOrder.vue @@ -17,9 +17,14 @@ - + @@ -33,7 +38,7 @@
@@ -141,10 +146,14 @@
- +
@@ -234,8 +243,9 @@ export default { products: [], productSelect: { page: 1, - page_size: 10 + page_size: 9999 }, + accountOptions: [], form: { customer_id: '', @@ -296,6 +306,22 @@ export default { } }, + toNumberId(value) { + if (value === '' || value === null || value === undefined) { + return '' + } + const id = Number(value) + return Number.isNaN(id) ? value : id + }, + ensureSelectOption(list, item) { + if (!item || item.id == null || !Array.isArray(list)) { + return + } + const exists = list.some(i => Number(i.id) === Number(item.id)) + if (!exists) { + list.unshift(item) + } + }, customLoad() { this.customSelect.page++ this.getCustomers() @@ -352,31 +378,36 @@ export default { }) return } - this.customers.push(...res.data.data) + res.data.data.forEach(item => { + const exists = this.customers.some(i => Number(i.id) === Number(item.id)) + if (!exists) { + this.customers.push(item) + } + }) }, - productLoad() { - this.productSelect.page++ - this.getProducts() - }, async getProducts() { - const res = await productList(this.productSelect, false) - if (res.data.length === 0) { - this.productSelect.page-- - this.$message({ - type: 'warning', - message: '没有跟多产品了' - }) - return - } - this.products.push(...res.data) + const res = await productList({ + page: 1, + page_size: 9999 + }, false) + const list = Array.isArray(res.data) ? res.data : (res.data?.data || []) + this.products = list + this.ensureSelectOption(this.products, this.pickedProduct) }, async getDetail(){ const res = await getForm(this.id) this.$integrateData(this.form,res) this.form.date = [res.start_date,res.end_date] - this.pickedProduct = res.product + this.form.customer_id = this.toNumberId(res.customer_id) + this.form.product_id = this.toNumberId(res.product_id) + this.form.product_type_id = this.toNumberId(res.product_type_id) + this.form.account_id = this.toNumberId(res.account_id) + this.pickedProduct = res.product || {} + this.ensureSelectOption(this.customers, res.customer) + this.ensureSelectOption(this.products, res.product) + this.ensureSelectOption(this.accountOptions, res.account) }, submit() { @@ -412,6 +443,8 @@ export default { watch: { isShow(val) { if (val) { + this.customSelect.page = 1 + this.accountOptions = [...(this.accounts || [])] this.getCustomers() this.getProducts() @@ -421,6 +454,7 @@ export default { } else { this.customers = [] this.products = [] + this.accountOptions = [] this.id = '' this.type = '' this.$refs['dialog'].reset() diff --git a/src/views/order/order.vue b/src/views/order/order.vue index 3ca7e68..cd8ba45 100644 --- a/src/views/order/order.vue +++ b/src/views/order/order.vue @@ -149,7 +149,7 @@ page: 1, page_size: 9999 }) - this.accounts = res.data + this.accounts = Array.isArray(res.data) ? res.data : (res.data?.data || []) }, async getOrder() { diff --git a/vue.config.js b/vue.config.js index 808a638..9dcfacb 100644 --- a/vue.config.js +++ b/vue.config.js @@ -26,7 +26,7 @@ module.exports = { */ publicPath: process.env.ENV === 'staging' ? '/admin_test' : '/admin/', // outputDir: '/Users/mac/Documents/朗业/2025/s-四世同堂-护工/sstt/public/admin', //测试 - outputDir: '/Users/mac/Documents/朗业/2025/s-四世同堂-护工/正式/sstt/public/admin', + outputDir: '/Users/mac/Documents/朗业/2025/s-四世同堂-护工/sstt/public/admin', assetsDir: 'static', css: { loaderOptions: { // 向 CSS 相关的 loader 传递选项