diff --git a/FlowerGully/package.json b/FlowerGully/package.json index ab62f4dd62d9711bf3ca77e472a6f4380a50edde..061a1389f6e3bd2e3688f3938ab4f8761f9a0895 100644 --- a/FlowerGully/package.json +++ b/FlowerGully/package.json @@ -23,6 +23,7 @@ "nprogress": "0.2.0", "path-to-regexp": "2.4.0", "vue": "2.6.10", + "vue-baidu-map": "^0.21.22", "vue-router": "3.0.6", "vuex": "3.1.0" }, diff --git a/FlowerGully/src/App.vue b/FlowerGully/src/App.vue index ec9032c1c638e918ec97e413aa081993a95048f4..f668ec649b97d1e945d634fca9d7287c2fe5544d 100644 --- a/FlowerGully/src/App.vue +++ b/FlowerGully/src/App.vue @@ -9,3 +9,6 @@ export default { name: 'App' } + + \ No newline at end of file diff --git "a/FlowerGully/src/assets/\345\233\276\347\211\207/\346\232\202\346\227\240\346\225\260\346\215\256.png" "b/FlowerGully/src/assets/\345\233\276\347\211\207/\346\232\202\346\227\240\346\225\260\346\215\256.png" new file mode 100644 index 0000000000000000000000000000000000000000..7ba6e5282dc120bffac112fa3e1abbbd2459fd32 Binary files /dev/null and "b/FlowerGully/src/assets/\345\233\276\347\211\207/\346\232\202\346\227\240\346\225\260\346\215\256.png" differ diff --git a/FlowerGully/src/main.js b/FlowerGully/src/main.js index 6111b9b1f7599cd87d09a6e977a0b33ff759b492..de3ce42abed3d3ba867d37630484eee7382aaf27 100644 --- a/FlowerGully/src/main.js +++ b/FlowerGully/src/main.js @@ -9,6 +9,7 @@ import '@/styles/index.scss' // global css import App from './App' import store from './store' import router from './router' +import BaiduMap from 'vue-baidu-map' import '@/icons' // icon import '@/permission' // permission control @@ -27,6 +28,10 @@ axios.defaults.baseURL = 'http://localhost:3000/api/'; Vue.use(ElementUI) Vue.config.productionTip = false +Vue.use(BaiduMap, { + // ak 是在百度地图开发者平台申请的密钥 详见 http://lbsyun.baidu.com/apiconsole/key */ + ak: 'apKWrd8UhmG4WNy4oX3GpoZlg3Fg7sRr' +}) new Vue({ el: '#app', diff --git a/FlowerGully/src/views/BasicInformation/Base.vue b/FlowerGully/src/views/BasicInformation/Base.vue index fac351c39b89004bf0e89dbc067049f098a8f178..ea9e22773fa3d30dbe771b98a39c265bb02e8414 100644 --- a/FlowerGully/src/views/BasicInformation/Base.vue +++ b/FlowerGully/src/views/BasicInformation/Base.vue @@ -5,7 +5,7 @@ style="display: flex; align-items: center; white-space: nowrap;justify-content: space-between;margin-bottom: 20px;"> 添加
- 基地名称: + 基地名称: 查询 重置 @@ -80,6 +80,7 @@ export default { }, //删除 open(id) { + console.log(id); this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', @@ -94,7 +95,7 @@ export default { type: 'success', message: '删除成功!' }); - if (this.pageSize * (this.currentPage - 1) < this.tableData.length) { + if (this.currentPage > 1 && this.pageSize * (this.currentPage - 1) < this.tableData.length) { this.currentPage = this.currentPage - 1 } this.getbase() @@ -143,6 +144,7 @@ export default { }, //重置 reset() { + this.inp = '' this.getbase() }, }, diff --git a/FlowerGully/src/views/BasicInformation/Greenhouse.vue b/FlowerGully/src/views/BasicInformation/Greenhouse.vue index 097e9bbe651936ba9f4217048195420f659c37b5..cd83068dc9c03f6ee9ea3f393ec4a7e6f4d79234 100644 --- a/FlowerGully/src/views/BasicInformation/Greenhouse.vue +++ b/FlowerGully/src/views/BasicInformation/Greenhouse.vue @@ -5,8 +5,8 @@ style="display: flex; align-items: center; white-space: nowrap;justify-content: space-between;margin-bottom: 20px;"> 添加
- 负责人: - 大棚名称: + 负责人: + 大棚名称: 查询 @@ -97,7 +97,7 @@ export default { type: 'success', message: '删除成功!' }); - if (this.pageSize * (this.currentPage - 1) < this.tableData.length) { + if (this.currentPage > 1 && this.pageSize * (this.currentPage - 1) < this.tableData.length) { this.currentPage = this.currentPage - 1 } this.getgreenhouse() @@ -155,6 +155,8 @@ export default { }, //重置 reset() { + this.inp = '' + this.inp1 = '' this.getgreenhouse() }, }, diff --git a/FlowerGully/src/views/BasicInformation/Personnel.vue b/FlowerGully/src/views/BasicInformation/Personnel.vue index de9668d56e907b6963b728407146d28e4d265249..f3ba47a2c791ef3a28d66525da9d3e05009784fc 100644 --- a/FlowerGully/src/views/BasicInformation/Personnel.vue +++ b/FlowerGully/src/views/BasicInformation/Personnel.vue @@ -3,8 +3,11 @@
- 负责大棚: - 姓名: + 负责大棚: + + + 姓名: 查询 @@ -41,6 +44,9 @@ export default { currentPage: 1, pageSize: 10, data: null, + //选项集合 + options: [], + datas: [], } }, methods: { @@ -70,6 +76,34 @@ export default { // console.log(this.tableData); }) }, + //基地获取 + getData(apiUrl, dataVariable, optionsVariable, name) { + this.$axios + .post(apiUrl, {}) + .then((res) => { + if (res.status != 200) return this.$message.error('获取失败!'); + + if (res.data.length == 0) { + this.$message({ + message: '暂无数据', + type: 'warning', + center: true + }); + } + dataVariable = res.data; + setTimeout(() => { + // 从响应中提取 value 字段的值作为下拉选项的数据 + optionsVariable.length = 0; // 清空数组 + res.data.forEach(option => { + optionsVariable.push({ + value: option[name], + label: option[name] + }); + }); + }, 1000); + console.log(111, dataVariable); + }); + }, //查询 search() { //自带模糊搜索 @@ -95,11 +129,14 @@ export default { }, //重置 reset() { + this.inp = '' + this.inp1 = '' this.getpersonnel() }, }, mounted() { this.getpersonnel() + this.getData('greenhouse/getpersonnel', this.datas, this.options, 'chargeGreenhouse'); }, } @@ -126,4 +163,22 @@ export default { color: #828282; font-weight: normal; } + +.custom-select { + margin-left: 10px; + margin-right: 10px; +} + +::v-deep .el-input--mini { + width: 200px; +} + +::v-deep .el-input__inner { + height: 28px; + line-height: 28px; +} + +::v-deep .el-select .el-input .el-select__caret { + line-height: 28px; +} \ No newline at end of file diff --git a/FlowerGully/src/views/BasicInformation/Variety.vue b/FlowerGully/src/views/BasicInformation/Variety.vue index 90dd97ebe9f80869cc8ef8d53ae8c372e337a422..1275ca2b17b1c1d21870b0f44c9b8ee76e049cef 100644 --- a/FlowerGully/src/views/BasicInformation/Variety.vue +++ b/FlowerGully/src/views/BasicInformation/Variety.vue @@ -8,8 +8,8 @@
作物种类 - + 作物名称 @@ -17,11 +17,11 @@
- +
- {{ item.label }} + {{ item.cropname }}
@@ -31,42 +31,52 @@
+ 新增 - 编辑 - 删除 + @click="btnadd(item.bid)">新增 + 编辑 + 删除

-
- -

{{ items.name }}

+
+ +
+
+ +

{{ items.breed }}

- 编辑|删除 + 编辑| + 删除
- 作物名称 - - 取 消 - 确 定 - + + + + +
+ 取 消 + 确 定 +
+
- 品种名称 + 品种名称

品种图片

- - + --> 取 消 确 定 @@ -79,126 +89,257 @@ export default { data() { return { - data: [{ - value: '1', - label: '粮食类', - botton: false, - formdata: [{ - id: 1, - name: '小麦', - imageurl: 'https://hbimg.huaban.com/c28f758bd3d5a4bf9732708ef8b0ca6e7bf137b1a3884-n91IE6_fw658', - }] - }], - options: [{ - value: '1', - label: '粮食类', - botton: false, - formdata: [{ - id: 1, - name: '小麦', - imageurl: 'https://hbimg.huaban.com/c28f758bd3d5a4bf9732708ef8b0ca6e7bf137b1a3884-n91IE6_fw658', - }, - { - id: 2, - name: '小麦2', - imageurl: 'https://hbimg.huaban.com/c28f758bd3d5a4bf9732708ef8b0ca6e7bf137b1a3884-n91IE6_fw658', - }, - { - id: 3, - name: '小麦3', - imageurl: 'https://hbimg.huaban.com/c28f758bd3d5a4bf9732708ef8b0ca6e7bf137b1a3884-n91IE6_fw658', - }, - { - id: 4, - name: '小麦4', - imageurl: 'https://hbimg.huaban.com/c28f758bd3d5a4bf9732708ef8b0ca6e7bf137b1a3884-n91IE6_fw658', - }], - }, - { - value: '2', - label: '水果类', - botton: false, - formdata: [{ - id: 1, - name: '香蕉', - imageurl: 'https://img0.baidu.com/it/u=493500101,221058570&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500', - }, - { - id: 2, - name: '香蕉2', - imageurl: 'https://img0.baidu.com/it/u=493500101,221058570&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500', - }, - { - id: 3, - name: '香蕉3', - imageurl: 'https://img0.baidu.com/it/u=493500101,221058570&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500', - }, - { - id: 4, - name: '香蕉4', - imageurl: 'https://img0.baidu.com/it/u=493500101,221058570&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500', - }], - }, - { - value: '3', - label: '蔬菜类', - botton: false, - formdata: [{ - id: 1, - name: '白菜', - imageurl: 'https://img.tuguaishou.com/designer_upload_asset/15/87/64/69/02/63/6355360842133c0e415e37d74e184ddc.png!w300_w?auth_key=2286806400-0-0-7d05afc060dd618b6950d4d2fd4a51f8', - }, - { - id: 2, - name: '白菜2', - imageurl: 'https://img.tuguaishou.com/designer_upload_asset/15/87/64/69/02/63/6355360842133c0e415e37d74e184ddc.png!w300_w?auth_key=2286806400-0-0-7d05afc060dd618b6950d4d2fd4a51f8', - }, - { - id: 3, - name: '白菜3', - imageurl: 'https://img.tuguaishou.com/designer_upload_asset/15/87/64/69/02/63/6355360842133c0e415e37d74e184ddc.png!w300_w?auth_key=2286806400-0-0-7d05afc060dd618b6950d4d2fd4a51f8', - }, - { - id: 4, - name: '白菜4', - imageurl: 'https://img.tuguaishou.com/designer_upload_asset/15/87/64/69/02/63/6355360842133c0e415e37d74e184ddc.png!w300_w?auth_key=2286806400-0-0-7d05afc060dd618b6950d4d2fd4a51f8', - }], - }], + inp: '', + options: [], value: '', input: '', dialogVisible: false, dialogVisible1: false, - type: '', - name: '', - imageUrl: '' //图片 + imageUrl: '', //图片 + ruleForm: { + bid: null, + cropname: '', + }, + rules: { + cropname: [{ required: true, message: '请输入', trigger: 'blur' }, { pattern: /^[\u4e00-\u9fa5]+$/, message: '作物名称必须为中文' }], + }, + ruleForm1: { + id: null, + cid: null, + breed: '', + c_pic: '', + }, + rules1: { + breed: [{ required: true, message: '请输入', trigger: 'blur' }, { pattern: /^[\u4e00-\u9fa5]+$/, message: '作物名称必须为中文' }], + c_pic: [{ required: true, message: '图片不能为空', trigger: 'blur' }] + }, }; }, methods: { changeIcon(item) { item.botton = !item.botton }, + handleCloses() { + this.ruleForm1 = { + id: null, + cid: null, + breed: '', + c_pic: '', + }, + this.ruleForm = { + bid: null, + cropname: '', + }, + this.dialogVisible1 = false + this.dialogVisible = false + }, handleClose(done) { done() }, - // handleAvatarSuccess(res, file) { - // this.imageUrl = URL.createObjectURL(file.raw); - // }, - // beforeAvatarUpload(file) { - // const isJPG = file.type === 'image/jpeg'; - // const isLt2M = file.size / 1024 / 1024 < 2; + //默认获取基地信息 get方法和post同步 get要比post快一步 意味着get获取的永远为旧数据 + async getcrop() { + await this.$axios.post("crop/getcropall", { + }, { + }).then((res) => { + if (res.status != 200) return this.$message.error('获取失败!'); + if (res.data.length == 0) { + this.$message({ + message: '暂无数据', + type: 'warning', + center: true + }); + } + console.log(res.data, 160); + // 用于存储最终结果的对象 + const result = {}; + + // 遍历数据数组 + res.data.forEach(item => { + const bid = item.bid; + const cropname = item.cropname + // 如果 result 对象中不存在该 bid 的属性,则初始化一个空数组 + if (!result[bid]) { + result[bid] = { + bid, + cropname, + botton: false, + formdata: [] + }; + } + + // 将当前数据对象添加到对应的 bid 分组中的 formdata 数组中 + result[bid].formdata.push({ + id: item.id, + breed: item.breed, + c_pic: item.c_pic + }); + }); + // 将 result 对象的值转为数组形式 + const finalResult = Object.values(result); + this.options = finalResult + console.log(111, this.options); + }) + }, + //添加/编辑大类 + addbcorp(formName) { + this.$refs[formName].validate((valid) => { + if (valid) { + this.$axios.post("crop/addbcrop", { + data: this.ruleForm + }, { + }).then((res) => { + if (res.status == 205) return this.$message.error('该基地名称已存在,操作失败!'); + if (res.status != 200) return this.$message.error('操作失败!'); + return this.$message({ + type: 'success', + message: '操作成功!' + }); + }) + setTimeout(() => { + this.getcrop() + }, 100) + this.dialogVisible = false + this.ruleForm = { + bid: null, + cropname: '', + } + } else { + console.log('error submit!!'); + return false; + } + + }); + + }, + //大类编辑 + deit(item) { + this.dialogVisible = true + this.ruleForm.bid = item.bid + this.ruleForm.cropname = item.cropname + }, + // 大类删除 + delbcrop(id) { + console.log(id); + this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }).then(() => { + this.$axios.post("crop/delbcrop", { + bid: id + }, { + }).then((res) => { + if (res.status != 200) return this.$message.error('删除失败!'); + this.$message({ + type: 'success', + message: '删除成功!' + }); + this.getcrop() + }) + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消删除' + }); + }); + }, + //小类图片 + handleImageUpload(event) { + const file = event.target.files[0]; + const reader = new FileReader(); + const isJPG = file.type === 'image/jpeg' || 'image/png'; + const isLt2M = file.size / 1024 / 1024 < 2; + if (!isJPG) { + this.$message.error('上传头像图片只能是 JPG/PNG 格式!'); + this.ruleForm1.c_pic = '' + } else if (!isLt2M) { + this.$message.error('上传头像图片大小不能超过 2MB!'); + this.ruleForm1.c_pic = '' + } else { + reader.onload = (event) => { + this.ruleForm1.c_pic = event.target.result; + }; + reader.readAsDataURL(file); + } + }, + //点击添加小类 + btnadd(id) { + this.dialogVisible1 = true + this.ruleForm1.cid = id + }, + //添加/编辑小类 + addcorp(formName) { + this.$refs[formName].validate((valid) => { + if (valid) { + this.$axios.post("crop/addcrop", { + data: this.ruleForm1 + }, { + }).then((res) => { + if (res.status == 205) return this.$message.error('该基地名称已存在,操作失败!'); + if (res.status != 200) return this.$message.error('操作失败!'); + return this.$message({ + type: 'success', + message: '操作成功!' + }); + }) + setTimeout(() => { + this.getcrop() + }, 100) + this.ruleForm1 = { + id: null, + cid: null, + breed: '', + c_pic: '', + }, + this.dialogVisible1 = false + + } else { + console.log('error submit!!'); + return false; + } - // if (!isJPG) { - // this.$message.error('上传头像图片只能是 JPG 格式!'); - // } - // if (!isLt2M) { - // this.$message.error('上传头像图片大小不能超过 2MB!'); - // } - // return isJPG && isLt2M; - // } + }); + }, + //点击编辑 + edit(items, item) { + this.ruleForm1.id = items.id + this.ruleForm1.cid = item.bid + this.ruleForm1.breed = items.breed + this.ruleForm1.c_pic = items.c_pic + this.dialogVisible1 = true + console.log(this.ruleForm1); + }, + //小类删除 + delcrop(id) { + this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }).then(() => { + this.$axios.post("crop/delcrop", { + id: id + }, { + }).then((res) => { + if (res.status != 200) return this.$message.error('删除失败!'); + this.$message({ + type: 'success', + message: '删除成功!' + }); + this.getcrop() + }) + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消删除' + }); + }); + }, + }, + mounted() { + this.getcrop() } } - diff --git a/FlowerGully/src/views/BasicInformation/compoents/BaseAddition.vue b/FlowerGully/src/views/BasicInformation/compoents/BaseAddition.vue index 8e71d29a3ece04a928f15cf5510cf7b43246f184..63ccbe9e0043b33f5909c27ee3f0cc523f39ca06 100644 --- a/FlowerGully/src/views/BasicInformation/compoents/BaseAddition.vue +++ b/FlowerGully/src/views/BasicInformation/compoents/BaseAddition.vue @@ -6,9 +6,8 @@ -
- -
+ +
@@ -59,6 +58,10 @@ export default { props: ['showDialog', 'message'], data() { return { + // 定位位置 + center: { lng: 114.228026, lat: 27.527942 }, + // 地图放大等级 + zoom: 12, ruleForm: { id: null, //大棚id baseName: '',//基地名字 @@ -118,7 +121,6 @@ export default { }, //表单清空 clfrom() { - this.ruleForm = { id: null, //大棚id beseName: '',//基地名字 @@ -215,4 +217,9 @@ export default { display: flex; justify-content: center; } + +// 去除百度地图的图标 根据实际情况看是否要加样式穿透(::v-deep) +::v-deep .anchorBL { + display: none !important; +} \ No newline at end of file diff --git a/FlowerGully/src/views/BasicInformation/compoents/GreenhouseAdd.vue b/FlowerGully/src/views/BasicInformation/compoents/GreenhouseAdd.vue index c833d40ba1bc33183c3abfa12490e47f953eeb27..1bf54f54e7c0a9287cac77a8c961658483f84130 100644 --- a/FlowerGully/src/views/BasicInformation/compoents/GreenhouseAdd.vue +++ b/FlowerGully/src/views/BasicInformation/compoents/GreenhouseAdd.vue @@ -6,9 +6,8 @@ -
- -
+ +
@@ -54,11 +53,16 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/FlowerGully/src/views/Equipment/VideoMonitoring.vue b/FlowerGully/src/views/Equipment/VideoMonitoring.vue index 75ffa69da0a137d6d6088b5f805f1537cfe059b5..8ec8906dae6c532e9fc85b65cd46fa1048845a86 100644 --- a/FlowerGully/src/views/Equipment/VideoMonitoring.vue +++ b/FlowerGully/src/views/Equipment/VideoMonitoring.vue @@ -32,7 +32,7 @@ - +