diff --git a/src/components/base-table/popup.vue b/src/components/base-table/popup.vue index c2268c5..f161283 100644 --- a/src/components/base-table/popup.vue +++ b/src/components/base-table/popup.vue @@ -18,11 +18,13 @@ v-for="(item, i) in columsList" :key="i" > - + + + diff --git a/src/components/search-form/components/ApiSelect1.vue b/src/components/search-form/components/ApiSelect1.vue index c373886..1f41657 100644 --- a/src/components/search-form/components/ApiSelect1.vue +++ b/src/components/search-form/components/ApiSelect1.vue @@ -48,6 +48,7 @@ export default { data() { return { show: false, + isFirstLoad: true, options: [], } }, @@ -103,7 +104,9 @@ export default { this.$emit('options-change', this.getOptions) }, handleConfirm(e) { + if (!e.length) return const { value } = e[0] + if (value == null) return this.$emit('change', value) this.$emit('input', value) }, @@ -111,5 +114,13 @@ export default { return typeof fn === 'function' }, }, + watch: { + params: { + handler() { + !this.isFirstLoad && this.fetch() + }, + deep: true, + }, + }, } diff --git a/src/components/search-form/components/Picker.vue b/src/components/search-form/components/Picker.vue new file mode 100644 index 0000000..4d9644e --- /dev/null +++ b/src/components/search-form/components/Picker.vue @@ -0,0 +1,84 @@ + + diff --git a/src/components/search-form/components/SearchItem.vue b/src/components/search-form/components/SearchItem.vue index 3c83a05..349cfbb 100644 --- a/src/components/search-form/components/SearchItem.vue +++ b/src/components/search-form/components/SearchItem.vue @@ -3,6 +3,7 @@ diff --git a/src/components/search-form/components/Select1.vue b/src/components/search-form/components/Select1.vue new file mode 100644 index 0000000..2ab3b1c --- /dev/null +++ b/src/components/search-form/components/Select1.vue @@ -0,0 +1,122 @@ + + diff --git a/src/pages.json b/src/pages.json index 4054be9..b8f638c 100644 --- a/src/pages.json +++ b/src/pages.json @@ -229,6 +229,38 @@ "enablePullDownRefresh": false, "navigationStyle":"custom" } + },{ + "path" : "pages/crop/town-crop", + "style" : + { + "navigationBarTitleText": "城镇农作物", + "enablePullDownRefresh": false, + "navigationStyle":"custom" + } + },{ + "path" : "pages/crop/basics-crop", + "style" : + { + "navigationBarTitleText": "基地农作物", + "enablePullDownRefresh": false, + "navigationStyle":"custom" + } + },{ + "path" : "pages/yield/town-yield", + "style" : + { + "navigationBarTitleText": "城镇产量", + "enablePullDownRefresh": false, + "navigationStyle":"custom" + } + },{ + "path" : "pages/yield/basics-yield", + "style" : + { + "navigationBarTitleText": "基地产量", + "enablePullDownRefresh": false, + "navigationStyle":"custom" + } } ], "globalStyle": { diff --git a/src/pages/basics/components/basics-edit.vue b/src/pages/basics/components/basics-edit.vue index c569a47..01f2446 100644 --- a/src/pages/basics/components/basics-edit.vue +++ b/src/pages/basics/components/basics-edit.vue @@ -166,9 +166,9 @@ export default { const params = { ...this.form, type: 1 } if (this.isEdit) { - this.onUpdate(params) + await this.onUpdate(params) } else { - this.onCreate(params) + await this.onCreate(params) } this.$emit('confirm') }, @@ -206,7 +206,6 @@ export default { watch: { data: { handler(val) { - console.log(val) if (val) { this.setDefaultForm(val) } diff --git a/src/pages/crop/basics-crop.vue b/src/pages/crop/basics-crop.vue new file mode 100644 index 0000000..dafb633 --- /dev/null +++ b/src/pages/crop/basics-crop.vue @@ -0,0 +1,237 @@ + + diff --git a/src/pages/crop/components/basics-edit.vue b/src/pages/crop/components/basics-edit.vue index c569a47..2efc7bf 100644 --- a/src/pages/crop/components/basics-edit.vue +++ b/src/pages/crop/components/basics-edit.vue @@ -7,59 +7,63 @@ - - - - - - - + - - + + - - - - - - - - - - - - - - - - + - - + + - - + + - - - - - - - - + + + + + + + + + + + + + + + + + @@ -77,41 +81,22 @@ import { http } from '@/api/index.js' import ApiSelect from '@/components/search-form/components/ApiSelect1.vue' import ApiCheckbox from '@/components/search-form/components/ApiCheckbox.vue' -const industrySelectOption = { +const categorySelectOption = { api: async (e) => { - const { data } = await http.get('/api/keywords-industry', { + const { data } = await http.get('/api/keywords-crops-cate', { params: e, }) return data.data }, labelField: 'name', - valueField: 'key', + valueField: 'id', } const parentSelectOption = { - api: async (e) => { - const { data } = await http.get('/api/agricultural-basic', { - params: { - type: 2, - }, - }) - console.log(data) - return data.data - }, - labelField: 'name', - valueField: 'id', -} -const cropsSelectOption = { api: async (e) => { const { data } = await http.get('/api/crops', { - params: { type: 'all', crop_type: 1 }, - }) - console.log(data) - return data.data.map((e) => { - return { - ...e, - disabled: e.is_end === 0, - } + params: e, }) + return data.data.filter(({ is_end }) => is_end != 1) }, labelField: 'name', valueField: 'id', @@ -123,6 +108,10 @@ export default { type: Object, default: () => {}, }, + crop_type: { + type: Number, + default: 2, + }, }, components: { ApiSelect, @@ -132,50 +121,66 @@ export default { isEdit() { return !!this.data }, + parentSelectOption() { + return { + ...parentSelectOption, + params: { + type: 'all', + crop_type: this.crop_type, + category: this.form.category_id, + }, + } + }, }, data() { return { - industrySelectOption, - parentSelectOption, - cropsSelectOption, + categorySelectOption, + form: { id: '', - is_blank: false, - blank_url: '', - industry_key: '', + category_id: '', name: '', - sort: 0, - person: '', - areas: '', - cultivated: '', - workforce: '', parent_id: '', - crops_ids: [], - address: '', - description: '', - address_lng: '', - address_lat: '', + unit: '', + is_end: false, + extends: [ + { + name: '', + unit: '', + }, + ], }, } }, methods: { + addDomain() { + this.form.extends.push({ + name: '', + unit: '', + }) + }, + removeDomain(index) { + this.form.extends.splice(index, 1) + }, + handleParentChange(e) { + // this.form.parent_id = '' + }, handleCancel() { this.$emit('cancel') }, async handleSubmit() { - const params = { ...this.form, type: 1 } - + const params = { ...this.form, crop_type: this.crop_type } if (this.isEdit) { - this.onUpdate(params) + await this.onUpdate(params) } else { - this.onCreate(params) + await this.onCreate(params) } this.$emit('confirm') }, async onUpdate(params) { try { - await this.$http.put(`/api/agricultural-basic/${params.id}`, params) + await this.$http.put(`/api/crops/${params.id}`, params) this.$u.toast('操作成功') } catch ({ data }) { data && this.$u.toast(data?.message) @@ -184,23 +189,28 @@ export default { async onCreate(params) { try { - await this.$http.post('/api/agricultural-basic', params) + await this.$http.post('/api/crops', params) this.$u.toast('操作成功') } catch ({ data }) { data && this.$u.toast(data?.message) } }, - setDefaultForm(data) { - Object.keys(data).forEach((key) => { - const value = data[key] - if (key == 'blank_url') { - this.form.is_blank = data[key] ? true : false - } else if (key == 'crops') { - this.form.crops_ids = value.map((e) => e.id) + async setDefaultForm(e) { + const { data } = await this.$http.get(`/api/crops/${e.id}`) + const { data: resData } = data + + Object.keys(e).forEach((key) => { + let value = e[key] + if (key == 'is_end') value = value == 1 + if (key == 'extends') { + if (value.length == 0) value = [{ name: '', unit: '' }] } if (this.form[key] !== undefined) this.form[key] = value }) + + this.form.category_id = resData?.category?.id + this.form.parent_id = resData?.parent_id > 0 ? resData?.parent_id : null }, }, watch: { diff --git a/src/pages/crop/town-crop.vue b/src/pages/crop/town-crop.vue index f65d2b3..53891ac 100644 --- a/src/pages/crop/town-crop.vue +++ b/src/pages/crop/town-crop.vue @@ -1,6 +1,6 @@