From a0654f2c21511a0e16b977427a563a3ccdfd1fba Mon Sep 17 00:00:00 2001 From: kongdeqiang <123456> Date: 星期二, 14 三月 2023 15:34:06 +0800 Subject: [PATCH] 搜索bug --- src/views/your/car-manage/carManage.vue | 341 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 278 insertions(+), 63 deletions(-) diff --git a/src/views/your/car-manage/carManage.vue b/src/views/your/car-manage/carManage.vue index 0f94c6a..0129cd1 100644 --- a/src/views/your/car-manage/carManage.vue +++ b/src/views/your/car-manage/carManage.vue @@ -8,15 +8,14 @@ <Card> <Row class="operation"> <Button @click="addCar" type="primary" icon="md-add">娣诲姞杞﹁締</Button> - <Button @click="delAll" icon="md-trash">鎵归噺鍒犻櫎</Button> <Button @click="init" icon="md-refresh">鍒锋柊</Button> <Button type="dashed" @click="openTip = !openTip">{{ openTip ? "鍏抽棴鎻愮ず" : "寮�鍚彁绀�" }}</Button> <Input - v-model="searchForm.carNo" + v-model="searchForm2.carNo" suffix="ios-search" - @on-change="getDataList" + @on-change="getDataList2" placeholder="杈撳叆杞︾墝鍙锋悳绱�" clearable style="width: 250px" @@ -60,12 +59,7 @@ :mask-closable="false" :width="500" > - <Form - ref="carForm" - :model="carForm" - :label-width="80" - :rules="carFormValidate" - > + <Form ref="carForm" :model="carForm" :label-width="80" :rules="carFormValidate"> <FormItem label="鍝佺墝" prop="brand"> <Input v-model="carForm.brand"/> </FormItem> @@ -86,7 +80,24 @@ <FormItem label="鐗岀収" prop="carNo"> <Input v-model="carForm.carNo" /> </FormItem> - + <FormItem label="鍔犳补鍗″彿" prop="addOilCode"> + <Input v-model="carForm.addOilCode" /> + </FormItem> + <FormItem label="杞﹁締缂栧彿" prop="code"> + <Input v-model="carForm.code" /> + </FormItem> + <FormItem label="鍙告満" prop="userId"> + <Select v-model="carForm.userId" filterable> + <Option :value="0">璇烽�夋嫨</Option> + <Option v-for="item in userList" :value="item.id" :key="item.id">{{ item.nickname }}</Option> + </Select> + </FormItem> + <FormItem label="閰嶉�佸憳" prop="followUserId"> + <Select v-model="carForm.followUserId" filterable> + <Option :value="0" :key="0">璇烽�夋嫨</Option> + <Option v-for="item in driverList" :value="item.id" :key="item.id">{{ item.nickname }}</Option> + </Select> + </FormItem> </Form> <div slot="footer"> <Button type="text" @click="carRole">鍙栨秷</Button> @@ -95,12 +106,50 @@ > </div> </Modal> - <Modal :title="modalTitle" v-model="equipmentVisible" :mask-closable="false" :width="1200"> + <Modal :title="modalTitle" v-model="equipmentVisible" :mask-closable="false" :width="1044"> + <Row class="operation" style="padding-bottom: 20px"> + <Button @click="addEquipment" type="primary" icon="md-add">娣诲姞璁惧</Button> + <Button @click="init" icon="md-refresh">鍒锋柊</Button> + </Row> <Table :loading="loading" border :columns="columns2" :data="data2" ref="table" sortable="custom" @on-sort-change="changeSort" @on-selection-change="changeSelect"> </Table> + </Modal> + <Modal :title="modalTitle" v-model="addEquipmentVisible" :mask-closable="false" :width="500"> + <Form ref="equipmentForm" :model="equipmentForm" :label-width="80" :rules="equipmentFormValidate"> + <FormItem label="璁惧绫诲瀷" prop="type"> + <Select v-model="equipmentForm.type"> + <Option :value="0">杞︽満</Option> + <Option :value="1">鎽勫儚鏈�</Option> + <Option :value="2">鎶撴媿鏈�</Option> + <Option :value="3">pad</Option> + </Select> + </FormItem> + <FormItem label="鐘舵��" prop="status"> + <Select v-model="equipmentForm.status"> + <Option :value="0">姝e父</Option> + <Option :value="1">寮傚父</Option> + </Select> + </FormItem> + <FormItem label="缂栧彿" prop="code"> + <Input v-model="equipmentForm.code" /> + </FormItem> + <FormItem label="ip鍦板潃" prop="ip"> + <Input v-model="equipmentForm.ip" /> + </FormItem> + <FormItem label="绔彛鍙�" prop="port"> + <Input v-model="equipmentForm.port" /> + </FormItem> + + </Form> + <div slot="footer"> + <Button type="text" @click="carRole">鍙栨秷</Button> + <Button type="primary" :loading="submitLoading" @click="submitEquipment" + >鎻愪氦</Button + > + </div> </Modal> <!-- 鑿滃崟鏉冮檺 --> <Drawer @@ -200,6 +249,10 @@ editCar, deleteCar, getEquipment, + addEquipment, + getUser, + getDriver, + deleteEquipment, } from "@/api/open"; import util from "@/libs/util.js"; export default { @@ -219,6 +272,7 @@ sortType: "desc", modalType: 0, roleModalVisible: false, + addEquipmentVisible: false, equipmentVisible: false, carModalVisible: false, permModalVisible: false, @@ -232,7 +286,21 @@ order: "desc", // 榛樿鎺掑簭鏂瑰紡 key: "", }, + searchForm2: { + // 鎼滅储妗嗗垵濮嬪寲瀵硅薄 + pageNumber: 1, // 褰撳墠椤垫暟 + pageSize: 10, // 椤甸潰澶у皬 + sort: "createTime", // 榛樿鎺掑簭瀛楁 + order: "desc", // 榛樿鎺掑簭鏂瑰紡 + key: "", + }, carForm: { + status : 0 + }, + type: { + type : 0 + }, + equipmentForm: { status : 0 }, removeForm: { @@ -259,8 +327,18 @@ { title: "杞︾墝鍙�", key: "carNo", - width: 100, + width: 110, sortable: true, + }, + { + title: "鍙告満", + key: "nickName", + width: 100, + }, + { + title: "閰嶉�佸憳", + key: "followNickName", + width: 100, }, { title: "鍝佺墝", @@ -276,12 +354,35 @@ title: "鎺掗噺", key: "displacement", width: 100, - sortable: true, + }, + { + title: "鍔犳补鍗″彿", + key: "addOilCode", + minWidth: 120, + // sortable: true, + render: (h, params) => { + return h("div",params.row.addOilCode=="undefined" ? '':params.row.addOilCode); + } + }, + { + title: "缂栧彿", + key: "code", + minWidth: 120, + tooltip:true, + // render: (h, params) => { + // return h("div",params.row.code=="undefined" ? '':params.row.code); + // } }, { title: "璐疆骞翠唤", key: "buyYear", minWidth: 120, + sortable: true, + }, + { + title: "鐧昏鏃ユ湡", + key: "createTime", + minWidth: 180, sortable: true, }, { @@ -322,6 +423,7 @@ title: "鎿嶄綔", key: "action", align: "center", + fixed: "right", width: 280, render: (h, params) => { return h("div", [ @@ -402,18 +504,54 @@ { title: "璁惧绫诲瀷", key: "type", - width: 100, + width: 130, sortable: true, + render: (h, params) => { + let re = ""; + if (params.row.type == 0) { + return h("div", [ + h("Badge", { + props: { + text: "杞︽満", + }, + }), + ]); + } else if (params.row.type == 1) { + return h("div", [ + h("Badge", { + props: { + text: "鎽勫儚鏈�", + }, + }), + ]); + }else if (params.row.type == 2) { + return h("div", [ + h("Badge", { + props: { + text: "鎶撴媿鏈�", + }, + }), + ]); + }else if (params.row.type == 3) { + return h("div", [ + h("Badge", { + props: { + text: "pad", + }, + }), + ]); + } + }, }, { title: "缂栧彿", key: "code", - width: 100, + width: 120, }, { title: "鐘舵��", key: "status", - width: 100, + width: 120, sortable: true, render: (h, params) => { let re = ""; @@ -431,7 +569,7 @@ h("Badge", { props: { status: "error", - text: "绉婚櫎", + text: "鍋滅敤", }, }), ]); @@ -441,12 +579,12 @@ { title: "ip鍦板潃", key: "ip", - width: 100, + width: 120, }, { title: "绔彛鍙�", key: "port", - width: 100, + width: 120, sortable: true, }, { @@ -461,39 +599,7 @@ { on: { click: () => { - this.equipment(params.row); - }, - }, - }, - "璁惧" - ), - h("Divider", { - props: { - type: "vertical", - }, - }), - h( - "a", - { - on: { - click: () => { - this.removeCar(params.row); - }, - }, - }, - "绉婚櫎杞﹁締" - ), - h("Divider", { - props: { - type: "vertical", - }, - }), - h( - "a", - { - on: { - click: () => { - this.edit(params.row); + this.editEquipment(params.row); }, }, }, @@ -509,7 +615,7 @@ { on: { click: () => { - this.remove(params.row); + this.removeEquipment(params.row); }, }, }, @@ -522,15 +628,20 @@ data: [], data2: [], total: 0, + total2: 0, permData: [], editRolePermId: "", selectAllFlag: false, depData: [], dataType: 0, + carId: '', + driverList: [], + userList: [], editDepartments: [], buyYear:'' }; }, + methods: { change1(e){ this.buyYear = e; @@ -538,7 +649,6 @@ init() { this.getDataList(); // 鑾峰彇鎵�鏈夎彍鍗曟潈闄愭爲 - this.getPermList(); }, renderContent(h, { root, node, data }) { let icon = ""; @@ -595,6 +705,22 @@ this.searchForm.pageSize = v; this.getDataList(); }, + getAllUser(){ + getDriver({type:0}).then((res)=>{ + if (res.success){ + this.userList=res.result; + } + }); + //this.type.type=1; + getDriver({type:1}).then((res)=>{ + if (res.success){ + this.driverList=res.result; + } + }); + this.type.type=0; + console.log(this.userList); + console.log(this.driverList); + }, changeSort(e) { this.searchForm.sort = e.key; this.searchForm.order = e.order; @@ -613,13 +739,23 @@ } }); }, - getEquipmentList() { + getDataList2() { this.loading = true; - getEquipment(this.searchForm).then((res) => { + getCarList(this.searchForm2).then((res) => { + this.loading = false; + if (res.success) { + this.data = res.result.records; + this.total = res.result.total; + } + }); + }, + getEquipmentList(carId) { + this.loading = true; + this.searchForm2.carId=carId; + getEquipment(this.searchForm2).then((res) => { this.loading = false; if (res.success) { this.data2 = res.result.records; - this.total = res.result.total; } }); }, @@ -651,6 +787,12 @@ this.roleModalVisible = false; }, submitCar() { + if(this.carForm.userId==undefined || this.carForm.userId==0){ + this.carForm.userId=""; + } + if(this.carForm.followUserId==undefined || this.carForm.followUserId==0){ + this.carForm.followUserId=""; + } this.carForm.buyYear = this.buyYear; this.$refs.carForm.validate((valid) => { if (valid) { @@ -679,6 +821,37 @@ } }); }, + submitEquipment() { + this.$refs.equipmentForm.validate((valid) => { + this.equipmentForm.carId = this.carId; + if (valid) { + if (this.modalType == 0) { + // 娣诲姞 + this.submitLoading = true; + addEquipment(this.equipmentForm).then((res) => { + this.submitLoading = false; + if (res.success) { + this.$Message.success("鎿嶄綔鎴愬姛"); + this.getEquipmentList(this.carId); + this.addEquipmentVisible = false; + this.getEquipmentList(this.carId); + } + }); + } else { + this.submitLoading = true; + addEquipment(this.equipmentForm).then((res) => { + this.submitLoading = false; + if (res.success) { + this.$Message.success("鎿嶄綔鎴愬姛"); + this.getEquipmentList(this.carId); + this.addEquipmentVisible = false; + } + }); + } + } + + }); + }, submitRemove(){ this.$refs.removeForm.validate((valid) => { if (valid) { @@ -694,8 +867,9 @@ } }); }, - equipment() { - this.getEquipmentList(); + equipment(row) { + this.carId = row.id + this.getEquipmentList(row.id); this.modalType = 0; this.modalTitle = "璁惧淇℃伅"; this.$refs.carForm.resetFields(); @@ -703,16 +877,27 @@ this.equipmentVisible = true; }, addCar() { + this.carForm={}; + this.getAllUser(); this.modalType = 0; this.modalTitle = "娣诲姞杞﹁締"; this.$refs.carForm.resetFields(); delete this.carForm.id; this.roleModalVisible = true; }, + addEquipment() { + this.equipmentForm={}; + this.modalType = 0; + this.modalTitle = "娣诲姞璁惧"; + this.$refs.carForm.resetFields(); + delete this.carForm.id; + this.addEquipmentVisible = true; + }, edit(v) { + this.getAllUser(); this.buyYear = v.buyYear; this.modalType = 1; - this.modalTitle = "缂栬緫瑙掕壊"; + this.modalTitle = "缂栬緫"; this.$refs.carForm.resetFields(); // 杞崲null涓�"" for (let attr in v) { @@ -722,9 +907,23 @@ } let str = JSON.stringify(v); let roleInfo = JSON.parse(str); - this.carForm = roleInfo; this.roleModalVisible = true; + }, + editEquipment(v) { + this.modalType = 1; + this.modalTitle = "缂栬緫璁惧"; + this.$refs.equipmentForm.resetFields(); + // 杞崲null涓�"" + for (let attr in v) { + if (v[attr] == null) { + v[attr] = ""; + } + } + let str = JSON.stringify(v); + let roleInfo = JSON.parse(str); + this.equipmentForm = roleInfo; + this.addEquipmentVisible = true; }, removeCar(v) { this.dataType = 0; @@ -739,7 +938,6 @@ let str = JSON.stringify(v); let roleInfo = JSON.parse(str); roleInfo.status=1 - console.log(roleInfo); this.removeForm = roleInfo; this.carModalVisible = true; @@ -756,6 +954,23 @@ this.clearSelectAll(); this.$Message.success("鍒犻櫎鎴愬姛"); this.getDataList(); + } + }); + }, + }); + }, + removeEquipment(v) { + this.$Modal.confirm({ + title: "纭鍒犻櫎", + content: "鎮ㄧ‘璁よ鍒犻櫎鍚� ", + loading: true, + onOk: () => { + deleteEquipment({ ids: v.id }).then((res) => { + this.$Modal.remove(); + if (res.success) { + this.clearSelectAll(); + this.$Message.success("鍒犻櫎鎴愬姛"); + this.getEquipmentList(this.carId); } }); }, @@ -1039,4 +1254,4 @@ this.init(); }, }; -</script> \ No newline at end of file +</script> -- Gitblit v1.9.1