From b64f0354ddc0bedc8a69aa0ac6694ed227cf617a Mon Sep 17 00:00:00 2001 From: ZhangXianQiang <1135831638@qq.com> Date: 星期二, 12 三月 2024 18:18:39 +0800 Subject: [PATCH] Merge branch 'master' of http://42.193.1.25:9521/r/zgyw-ui --- src/views/system/point/index.vue | 181 ++++++----------- src/api/platform/region.js | 61 ++++++ src/views/system/region/index.vue | 351 +++++++++++++++++++++++++++++++++++ 3 files changed, 475 insertions(+), 118 deletions(-) diff --git a/src/api/platform/region.js b/src/api/platform/region.js new file mode 100644 index 0000000..61a01e7 --- /dev/null +++ b/src/api/platform/region.js @@ -0,0 +1,61 @@ +import request from '@/utils/request' + +// 鏌ヨ鍦板煙鍒楄〃 +export function listRegion(query) { + return request({ + url: '/region/page', + method: 'post', + data: query + }) +} + +// 鏌ヨ鍦板煙璇︾粏 +export function getRegion(id) { + return request({ + url: '/region/' + id, + method: 'get' + }) +} + +// 鏂板鍦板煙 +export function addRegion(data) { + return request({ + url: '/region', + method: 'post', + data: data + }) +} + +// 淇敼鍦板煙 +export function updateRegion(data) { + return request({ + url: '/region', + method: 'put', + data: data + }) +} + +// 鍒犻櫎鍦板煙 +export function delRegion(id) { + return request({ + url: '/region/' + id, + method: 'delete' + }) +} + +// 鑾峰彇鍖哄幙鍒楄〃 +export function getCountyList() { + return request({ + url: '/region/counties', + method: 'get' + }) +} + +// 鑾峰彇鍖哄幙绾ц仈閫夋嫨 +export function getCascader() { + return request({ + url: '/region/cascader', + method: 'get' + }) +} + diff --git a/src/views/system/point/index.vue b/src/views/system/point/index.vue index 05ca375..d12157b 100644 --- a/src/views/system/point/index.vue +++ b/src/views/system/point/index.vue @@ -87,7 +87,7 @@ <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span> </template> </el-table-column> - <el-table-column label="杩愮淮鍗曚綅" align="center" prop="unitId" /> + <el-table-column label="杩愮淮鍗曚綅" align="center" prop="unitName" /> <el-table-column label="杩愮淮鐘舵��" align="center" prop="status" /> <el-table-column label="澶囨敞" align="center" prop="remark" /> <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width"> @@ -118,85 +118,12 @@ <!-- 娣诲姞杩愮淮鐐逛綅瀵硅瘽妗� --> <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body> - <el-form ref="form" :model="tempForm" :rules="rules" label-width="120px"> - <el-form-item label="鐐逛綅鍚嶇О" prop="pointName"> - <el-input v-model="tempForm.pointName" placeholder="璇疯緭鍏ョ偣浣嶅悕绉�" /> - </el-form-item> - <el-form-item label="杩愮淮鍗曚綅" prop="unitId"> - <el-select v-model="tempForm.unitId" placeholder="杩愮淮鍗曚綅"> - <el-option - v-for="item in unitList" - :key="item.id" - :label="item.value" - :value="item.id"> - </el-option> - </el-select> - </el-form-item> - <el-form-item label="鐐逛綅鏃跺尯" prop="timezone"> - <el-date-picker - @change="dateChange" - v-model="tempForm.timezone" - type="daterange" - align="right" - unlink-panels - range-separator="鑷�" - start-placeholder="寮�濮嬫棩鏈�" - end-placeholder="缁撴潫鏃ユ湡" - > - </el-date-picker> - </el-form-item> - <el-form-item> - <div style="display: flex;flex-direction: row-reverse"> - <el-button @click="nextAdd" type="primary" plain>缁х画娣诲姞</el-button> - </div> - </el-form-item> - <div class="point-row" v-for="(point,index) in tempFormList"> - <div class="row-item"> - <el-input :disabled="editingIndex!==index" v-model="point.pointName" placeholder="鐐逛綅鍚嶇О"></el-input> - </div> - <div class="row-item"> - <el-select :disabled="editingIndex!==index" v-model="point.unitId" placeholder="杩愮淮鍗曚綅"> - <el-option - v-for="item in unitList" - :key="item.id" - :label="item.value" - :value="item.id"> - </el-option> - </el-select> - </div> - <div class="row-item"> - <el-date-picker - :disabled="editingIndex!==index" - v-model="point.timezone" - type="daterange" - align="right" - unlink-panels - range-separator="鑷�" - start-placeholder="寮�濮嬫棩鏈�" - end-placeholder="缁撴潫鏃ユ湡" - > - </el-date-picker> - </div> - <div class="row-item"> - <el-button v-show="editingIndex!==index" @click="editPointItem(index)" type="danger" size="small" plain>淇敼</el-button> - <el-button v-show="editingIndex===index" @click="editFinishItem(index)" type="success" size="small" plain>瀹屾垚</el-button> - </div> - </div> - </el-form> - <div slot="footer" class="dialog-footer"> - <el-button type="primary" @click="submitForm">纭� 瀹�</el-button> - <el-button @click="cancel">鍙� 娑�</el-button> - </div> - </el-dialog> - - <!-- 淇敼杩愮淮鐐逛綅瀵硅瘽妗� --> - <el-dialog :title="title" :visible.sync="editOpen" width="500px" append-to-body> <el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form-item label="鐐逛綅鍚嶇О" prop="pointName"> <el-input v-model="form.pointName" placeholder="璇疯緭鍏ョ偣浣嶅悕绉�" /> </el-form-item> <el-form-item label="杩愮淮鍗曚綅" prop="unitId"> - <el-select v-model="form.unitId" placeholder="杩愮淮鍗曚綅"> + <el-select :disabled="title === '淇敼杩愮淮鐐逛綅'" v-model="form.unitId" placeholder="杩愮淮鍗曚綅"> <el-option v-for="item in unitList" :key="item.id" @@ -207,6 +134,7 @@ </el-form-item> <el-form-item label="鐐逛綅鏃跺尯" prop="timezone"> <el-date-picker + :disabled="title === '淇敼杩愮淮鐐逛綅'" @change="dateChange" v-model="form.timezone" type="daterange" @@ -218,23 +146,41 @@ > </el-date-picker> </el-form-item> + <el-form-item> + <div style="display: flex;flex-direction: row-reverse"> + <el-button @click="nextAdd" type="primary" plain>娣诲姞鐐逛綅</el-button> + </div> + </el-form-item> + <el-row style="min-height: 200px;max-height: 400px; overflow-y: auto"> + <el-col class="col-item" v-for="(point) in tempFormList" :span="8"> + <div style="margin-right: 5px"> + <el-cascader v-model="point.region" :options="regionList" placeholder="璇烽�夋嫨鍖哄煙" :show-all-levels="false"></el-cascader> + </div> + <div v-if="title === '淇敼杩愮淮鐐逛綅'"> + <el-button @click="removeRegion(point)" type="danger" icon="el-icon-delete" circle></el-button> + </div> + </el-col> + </el-row> </el-form> <div slot="footer" class="dialog-footer"> <el-button type="primary" @click="submitForm">纭� 瀹�</el-button> - <el-button @click="updateCancel">鍙� 娑�</el-button> + <el-button @click="cancel">鍙� 娑�</el-button> </div> </el-dialog> + </div> </template> <script> import { listPoint, getPoint, delPoint, addPoint, addPointBatch, updatePoint } from "@/api/platform/point"; import { unitSelect } from "@/api/platform/unit"; +import { getCascader } from '../../../api/platform/region' export default { name: "Point", data() { return { + regionList: [], // 姝e湪淇敼绗嚑涓� editingIndex: null, // 閬僵灞� @@ -296,8 +242,18 @@ created() { this.getList(); this.getUnitSelect(); + this.getCascader(); }, methods: { + removeRegion(item) { + this.tempFormList = this.tempFormList.filter(data => data !== item) + }, + // 鑾峰彇鍖哄幙绾ц仈 + getCascader() { + getCascader().then(res => { + this.regionList = res.data; + }) + }, // 鐐逛綅椤逛慨鏀瑰畬鎴� editFinishItem(index) { this.editingIndex = null; @@ -322,9 +278,9 @@ }, // 缁х画娣诲姞鐐逛綅 nextAdd() { - this.formList.push(this.tempForm); - this.tempFormList.push(this.tempForm); - this.tempForm = {}; + let item = {} + // this.formList.push(item); + this.tempFormList.push(item); }, getUnitSelect() { // 杩愮淮鍗曚綅涓嬫媺鍒楄〃 @@ -362,7 +318,8 @@ remark: null, createTime: null, updateTime: null, - deleted: null + deleted: null, + pointDetail: "" }; this.resetForm("form"); }, @@ -379,7 +336,7 @@ // 澶氶�夋閫変腑鏁版嵁 handleSelectionChange(selection) { this.ids = selection.map(item => item.id) - this.single = selection.length!==1 + this.single = selection.length !== 1 this.multiple = !selection.length }, /** 鏂板鎸夐挳鎿嶄綔 */ @@ -395,39 +352,31 @@ getPoint(id).then(response => { this.form = response.data; this.form.timezone = [this.form.startTime, this.form.endTime] - this.editOpen = true; + if (this.form.pointDetail) { + this.tempFormList = JSON.parse(this.form.pointDetail) + } + this.open = true; this.title = "淇敼杩愮淮鐐逛綅"; }); }, /** 鎻愪氦鎸夐挳 */ submitForm() { - if (this.formList.length > 0) { - // 鎵归噺澧炲姞 - if (this.formList.every(item => !item.hasOwnProperty("id"))) { - addPointBatch(this.formList).then(response => { - this.$modal.msgSuccess("鏂板鎴愬姛"); - this.open = false; - // 閲嶇疆 - this.tempForm = {}; - this.tempFormList = []; - this.formList = []; - this.getList(); - }); - } - }else { - if (this.form.id != null) { - updatePoint(this.form).then(response => { - this.$modal.msgSuccess("淇敼鎴愬姛"); - this.editOpen = false; - this.getList(); - }); - } else { - addPoint(this.form).then(response => { - this.$modal.msgSuccess("鏂板鎴愬姛"); - this.open = false; - this.getList(); - }); - } + if (this.tempFormList) { + this.form.pointDetail = JSON.stringify(this.tempFormList) + } + if (this.form.id != null) { + updatePoint(this.form).then(response => { + this.$modal.msgSuccess("淇敼鎴愬姛"); + this.open = false; + this.getList(); + }); + } else { + addPoint(this.form).then(response => { + this.$modal.msgSuccess("鏂板鎴愬姛"); + this.open = false; + this.reset() + this.getList(); + }); } }, /** 鍒犻櫎鎸夐挳鎿嶄綔 */ @@ -438,7 +387,8 @@ }).then(() => { this.getList(); this.$modal.msgSuccess("鍒犻櫎鎴愬姛"); - }).catch(() => {}); + }).catch(() => { + }); }, /** 瀵煎嚭鎸夐挳鎿嶄綔 */ handleExport() { @@ -451,16 +401,11 @@ </script> <style scoped> -.point-row { +.col-item { + margin: 5px 0; display: flex; flex-direction: row; + align-content: center; justify-content: center; - align-items: center; -} -.row-item { - margin-right: 5px; -} -.row-item:nth-last-child { - margin-right: 0; } </style> diff --git a/src/views/system/region/index.vue b/src/views/system/region/index.vue new file mode 100644 index 0000000..6df087a --- /dev/null +++ b/src/views/system/region/index.vue @@ -0,0 +1,351 @@ +<template> + <div class="app-container"> + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> + <el-form-item label="鍦版柟鍏ㄧО" prop="fullName"> + <el-input + v-model="queryParams.fullName" + placeholder="璇疯緭鍏ュ湴鏂瑰叏绉�" + clearable + @clear="handleQuery" + @keyup.enter.native="handleQuery" + /> + </el-form-item> + <el-form-item label="鍦版柟绠�绉�" prop="simpleName"> + <el-input + v-model="queryParams.simpleName" + placeholder="璇疯緭鍏ュ湴鏂圭畝绉�" + clearable + @clear="handleQuery" + @keyup.enter.native="handleQuery" + /> + </el-form-item> + <el-form-item label="鍖哄幙" prop="county"> + <el-select v-model="queryParams.parentId" clearable @change="handleQuery" placeholder="璇烽�夋嫨鍖哄幙"> + <el-option v-for="item in countyList" :label="item.value" :value="item.id" :key="item.id"/> + </el-select> + </el-form-item> + <el-form-item label="鍦版柟绾у埆" prop="county"> + <el-select v-model="queryParams.regionLevel" clearable @change="handleQuery" placeholder="璇烽�夋嫨鍖哄幙"> + <el-option label="甯�" value="city" /> + <el-option label="鍖哄幙" value="county" /> + <el-option label="琛楅亾" value="street" /> + </el-select> + </el-form-item> + <el-form-item> + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button> + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button> + </el-form-item> + </el-form> + + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button + type="primary" + plain + icon="el-icon-plus" + size="mini" + @click="handleAdd" + v-hasPermi="['system:region:add']" + >鏂板</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="success" + plain + icon="el-icon-edit" + size="mini" + :disabled="single" + @click="handleUpdate" + v-hasPermi="['system:region:edit']" + >淇敼</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="danger" + plain + icon="el-icon-delete" + size="mini" + :disabled="multiple" + @click="handleDelete" + v-hasPermi="['system:region:remove']" + >鍒犻櫎</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="warning" + plain + icon="el-icon-download" + size="mini" + @click="handleExport" + v-hasPermi="['system:region:export']" + >瀵煎嚭</el-button> + </el-col> + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> + </el-row> + + <el-table v-loading="loading" + :data="regionList" + row-key="id" + border + default-expand-all + :tree-props="{children: 'children', hasChildren: 'hasChildren'}" + @selection-change="handleSelectionChange"> + <el-table-column type="selection" width="55" align="center" /> + <el-table-column label="鍖哄煙鍏ㄧО" align="center" prop="fullName" /> + <el-table-column label="鍖哄煙绠�绉�" align="center" prop="simpleName" /> + <el-table-column label="鍦板煙绾у埆" align="center"> + <template slot-scope="scope"> + <el-tag :type="typeByLevel(scope.row.regionLevel)" size="medium">{{ scope.row.regionLevel }}</el-tag> + </template> + </el-table-column> + <el-table-column label="甯�" align="center" prop="city" /> + <el-table-column label="鍖哄幙" align="center" prop="county" /> + <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width"> + <template slot-scope="scope"> + <el-button + size="mini" + type="text" + icon="el-icon-edit" + @click="handleUpdate(scope.row)" + v-hasPermi="['system:region:edit']" + >淇敼</el-button> + <el-button + size="mini" + type="text" + icon="el-icon-delete" + @click="handleDelete(scope.row)" + v-hasPermi="['system:region:remove']" + >鍒犻櫎</el-button> + </template> + </el-table-column> + </el-table> + + <pagination + v-show="total>0" + :total="total" + :page.sync="queryParams.pageNum" + :limit.sync="queryParams.pageSize" + @pagination="getList" + /> + + <!-- 娣诲姞鎴栦慨鏀瑰湴鍩熷璇濇 --> + <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> + <el-form-item label="甯�" prop="city"> + <el-input v-model="form.city" disabled /> + </el-form-item> + <el-form-item label="鍖哄幙" prop="county"> + <el-select v-model="form.parentId" @change="changeCounty" placeholder="璇烽�夋嫨鍖哄幙"> + <el-option v-for="item in countyList" :label="item.value" :value="item.id" :key="item.id"/> + </el-select> + </el-form-item> + <el-form-item label="鍦版柟鍏ㄧО" prop="fullName"> + <el-input v-model="form.fullName" type="textarea" placeholder="璇疯緭鍏ュ湴鏂瑰叏绉�" /> + </el-form-item> + <el-form-item label="鍦版柟绠�绉�" prop="simpleName"> + <el-input v-model="form.simpleName" placeholder="璇疯緭鍏ュ湴鏂圭畝绉�" /> + </el-form-item> + </el-form> + <div slot="footer" class="dialog-footer"> + <el-button type="primary" @click="submitForm">纭� 瀹�</el-button> + <el-button @click="cancel">鍙� 娑�</el-button> + </div> + </el-dialog> + </div> +</template> + +<script> +import { listRegion, getRegion, delRegion, addRegion, updateRegion, getCountyList } from "@/api/platform/region"; + +export default { + name: "Region", + data() { + return { + // 鍖哄幙鍒楄〃 + countyList: [], + // 閬僵灞� + loading: true, + // 閫変腑鏁扮粍 + ids: [], + // 闈炲崟涓鐢� + single: true, + // 闈炲涓鐢� + multiple: true, + // 鏄剧ず鎼滅储鏉′欢 + showSearch: true, + // 鎬绘潯鏁� + total: 0, + // 鍦板煙琛ㄦ牸鏁版嵁 + regionList: [], + // 寮瑰嚭灞傛爣棰� + title: "", + // 鏄惁鏄剧ず寮瑰嚭灞� + open: false, + // 鐖剁骇id鏃堕棿鑼冨洿 + daterangeCreateTime: [], + // 鏌ヨ鍙傛暟 + queryParams: { + pageNum: 1, + pageSize: 10, + fullName: null, + simpleName: null, + regionLevel: null, + parentId: null, + }, + // 琛ㄥ崟鍙傛暟 + form: { + id: null, + fullName: null, + simpleName: null, + regionLevel: null, + city: "鑷础甯�", + county: null, + parentId: null, + createTime: null, + updateTime: null, + deleted: null + }, + // 琛ㄥ崟鏍¢獙 + rules: { + fullName: [ + { required: true, message: "鍖哄煙鍏ㄧО涓嶈兘涓虹┖", trigger: "blur" } + ], + simpleName: [ + { required: true, message: "鍖哄煙绠�绉颁笉鑳戒负绌�", trigger: "blur" } + ], + countyId: [ + { required: true, message: "璇烽�夋嫨鍖哄幙", trigger: "change" } + ], + } + }; + }, + created() { + this.getList(); + this.getCountyList(); + }, + methods: { + typeByLevel(level) { + if (level === "甯�") { + return "danger" + } + if (level === "鍖哄幙") { + return "success" + } + }, + //鏀瑰彉鍖哄幙鏃讹紝淇敼parentId + changeCounty(value) { + this.form.county = this.countyList.filter(item => item.id === value)[0].value + }, + // 鑾峰彇鍖哄幙鍒楄〃 + getCountyList() { + getCountyList().then(res => { + this.countyList = res.data; + }) + }, + /** 鏌ヨ鍦板煙鍒楄〃 */ + getList() { + this.loading = true; + this.queryParams.params = {}; + if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) { + this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0]; + this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1]; + } + listRegion(this.queryParams).then(response => { + this.regionList = response.data; + this.total = response.total; + this.loading = false; + }); + }, + // 鍙栨秷鎸夐挳 + cancel() { + this.open = false; + this.reset(); + }, + // 琛ㄥ崟閲嶇疆 + reset() { + this.form = { + id: null, + fullName: null, + simpleName: null, + regionLevel: null, + city: "鑷础甯�", + county: null, + parentId: null, + createTime: null, + updateTime: null, + deleted: null + }; + this.resetForm("form"); + }, + /** 鎼滅储鎸夐挳鎿嶄綔 */ + handleQuery() { + this.queryParams.pageNum = 1; + this.getList(); + }, + /** 閲嶇疆鎸夐挳鎿嶄綔 */ + resetQuery() { + this.daterangeCreateTime = []; + this.resetForm("queryForm"); + this.handleQuery(); + }, + // 澶氶�夋閫変腑鏁版嵁 + handleSelectionChange(selection) { + this.ids = selection.map(item => item.id) + this.single = selection.length!==1 + this.multiple = !selection.length + }, + /** 鏂板鎸夐挳鎿嶄綔 */ + handleAdd() { + this.reset(); + this.open = true; + this.title = "娣诲姞鍦板煙"; + }, + /** 淇敼鎸夐挳鎿嶄綔 */ + handleUpdate(row) { + this.reset(); + const id = row.id || this.ids + getRegion(id).then(response => { + this.form = response.data; + this.open = true; + this.title = "淇敼鍦板煙"; + }); + }, + /** 鎻愪氦鎸夐挳 */ + submitForm() { + this.$refs["form"].validate(valid => { + if (valid) { + if (this.form.id != null) { + updateRegion(this.form).then(response => { + this.$modal.msgSuccess("淇敼鎴愬姛"); + this.open = false; + this.getList(); + }); + } else { + addRegion(this.form).then(response => { + this.$modal.msgSuccess("鏂板鎴愬姛"); + this.open = false; + this.getList(); + }); + } + } + }); + }, + /** 鍒犻櫎鎸夐挳鎿嶄綔 */ + handleDelete(row) { + const ids = row.id || this.ids; + this.$modal.confirm('鏄惁纭鍒犻櫎鍦板煙缂栧彿涓�"' + ids + '"鐨勬暟鎹」锛�').then(function() { + return delRegion(ids); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("鍒犻櫎鎴愬姛"); + }).catch(() => {}); + }, + /** 瀵煎嚭鎸夐挳鎿嶄綔 */ + handleExport() { + this.download('system/region/export', { + ...this.queryParams + }, `region_${new Date().getTime()}.xlsx`) + } + } +}; +</script> -- Gitblit v1.8.0