From ec129b718bc1a5c7192064f7ca3137401a801a77 Mon Sep 17 00:00:00 2001 From: lkk <364857242@qq.com> Date: 星期一, 28 四月 2025 14:18:47 +0800 Subject: [PATCH] 1 --- src/components/public/index.vue | 494 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 252 insertions(+), 242 deletions(-) diff --git a/src/components/public/index.vue b/src/components/public/index.vue index ae1d682..c1d8e31 100644 --- a/src/components/public/index.vue +++ b/src/components/public/index.vue @@ -1,18 +1,16 @@ <template> <div> - <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> + <el-dialog :title="title" :visible.sync="open" width="1080px" append-to-body> <h3 v-if="fList.proResult">妫�娴嬮」鐩� :{{ fList.project.proName }}</h3> <h3 v-if="fList.proResult"> 妫�娴嬬粨鏋� :{{ fList.proResult }}{{ fList.project.proMetering }} </h3> - <el-form - :model="queryParams" - ref="queryForm" - size="small" - :inline="true" - label-width="68px" - > - <el-form-item label="鐥呯鍚嶇О" prop="bingzhong"> + + <h2 style="text-align: center;">{{ proName || '鏆傛棤椤圭洰鍚嶇О' }}</h2> + <div style="display: flex; width: 100%"> + <div style="width: 50%; margin-right: 40px"> + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px" @submit.native.prevent> + <!-- <el-form-item label="鐥呯鍚嶇О" prop="bingzhong"> <el-input v-model="queryParams.bingzhong" placeholder="璇疯緭鍏ョ畝绉�" @@ -20,291 +18,303 @@ @keyup.enter.native="handleQuery" style="width: 120px" /> - </el-form-item> - <el-form-item label="鎷奸煶鐮�" prop="bzPinyin"> - <el-input - v-model="queryParams.bzPinyin" - placeholder="璇疯緭鍏ユ嫾闊崇爜" - clearable - @keyup.enter.native="handleQuery" - style="width: 130px" - /> - </el-form-item> - <el-form-item> - <el-button - type="primary" - icon="el-icon-search" - size="mini" - @click="handleQuery" - >鎼滅储</el-button - > - </el-form-item> - </el-form> - <el-table - :data="dataList" - ref="multipleTable" - v-loading="loading" - @selection-change="handleSelectionChange" - border - height="320px - " - > - <el-table-column type="selection" width="40" align="center" /> - <el-table-column label="搴忓彿" type="index" width="80px" /> - <!-- <el-table-column label="瑙勫垯" align="center" prop="ruleStr" /> --> - <el-table-column label="妫�鏌ョ粨璁�" align="center" prop="ruleStr" /> - <el-table-column label="妫�鏌ユ墍瑙�" align="center" prop="yxbx" /> - </el-table> - <div class="pag"> - <div class="pag1"> - <pagination - v-show="total > 0" - :total="total" - :page.sync="queryParams.pageNum" - :limit.sync="queryParams.pageSize" - @pagination="getList" - /> + </el-form-item>--> + <el-form-item label="妫�鏌ョ粨璁�" prop="ruleStr"> + <el-input v-model="queryParams.ruleStr" placeholder="璇疯緭鍏ユ鏌ョ粨璁�" clearable @keyup.enter.native="getList" + style="width: 130px" /> + </el-form-item> + <el-form-item> + <el-button type="primary" icon="el-icon-search" size="mini" @click="getList">鎼滅储</el-button> + </el-form-item> + <!-- <el-form-item> + <h3 >{{ queryParams.proName || '鏆傛棤椤圭洰鍚嶇О' }}</h3> + </el-form-item> --> + <!-- <el-form-item> + <h3 style="margin-left: 160px">宸查�夐」鐩�</h3> + </el-form-item> --> + </el-form> + <el-table :data="dataList" ref="multipleTable" v-loading="loading" @selection-change="handleSelectionChange" + border height="480px"> + <el-table-column type="selection" width="40" align="center" /> + <el-table-column label="搴忓彿" type="index" align="center" width="50px" /> + <!-- <el-table-column label="瑙勫垯" align="center" prop="ruleStr" /> --> + <el-table-column label="妫�鏌ユ墍瑙�" align="center" prop="yxbx" /> + <el-table-column label="妫�鏌ョ粨璁�" align="center" prop="ruleStr" /> + </el-table> + <div class="pag"> + <div class="pag1" style="margin-left: 630px"> + <pagination small v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" + :limit.sync="queryParams.pageSize" @pagination="getList" /> + </div> + </div> + </div> + + <div class="jianc"> + <!-- <h3 style="margin-top: -30px;">宸查�夐」鐩�</h3> --> + <el-form :model="form" ref="queryForm" size="small" label-width="68px" :label-position="labelPosition"> + <!-- :inline="true" --> + <!-- <el-form-item> + <el-input + type="textarea" + v-model="form.desc" + style="width: 560px" + ></el-input> + </el-form-item> --> + <el-form-item label="妫�鏌ユ墍瑙�" prop="jcsj"> + <el-input v-model="form.jcsj" clearable type="textarea" :autosize="{ minRows: 7 }" style="width: 380px" /> + </el-form-item> + <el-form-item label="妫�鏌ョ粨璁�" prop="desc"> + <el-input v-model="form.desc" clearable type="textarea" :autosize="{ minRows: 7 }" style="width: 380px" /> + </el-form-item> + </el-form> </div> </div> - <h3>宸查�夐」鐩�</h3> - <el-form - :model="form" - ref="queryForm" - size="small" - :inline="true" - label-width="68px" - > - <el-form-item> - <el-input - type="textarea" - v-model="form.desc" - style="width: 560px" - ></el-input> - </el-form-item> - </el-form> - <span slot="footer" class="dialog-footer"> - <el-button @click="open = false">鍙� 娑�</el-button> + + <span slot="footer" class="dialog-footer" style="margin-top: -20px"> + <el-button @click="callcolos">鍙� 娑�</el-button> <el-button type="primary" @click="handleOk">纭� 瀹�</el-button> </span> </el-dialog> </div> </template> - + <script> import { getlist, getlistByRuleStr } from "@/api/doctor/check"; +import { getYxJcXxJg } from "@/api/picture/picture"; export default { name: "Public", - - /* props: { - row: { - type: Object, - }, - }, */ props: { - lastDesc: { + checkStatus: { + type: String, + default: "0", + validator: (value) => ["0", "1"].includes(value), + }, + proResult: { type: String, default: "", + }, + conclusion: { + type: String, + default: "", + }, + projectList: { + type: Array, + default: () => [], }, }, data() { return { open: false, + labelPosition: "top", // 寮瑰嚭灞傛爣棰� title: "", - yxbx:"", + yxbx: "", + proName: '', // lastDesc: "", total: 0, dataList: [], // 閬僵灞� loading: false, form: { - // desc: "", - desc: this.lastDesc, + desc: "", + jcsj: "", }, queryParams: { - bingzhong: "", - bzPinyin: "", + ruleStr: "", pageNum: 1, pageSize: 10, }, list: [], fList: {}, selectedItems: [], + searchDebounce: null, }; }, watch: { - row(val, newVla) { - // console.log(val,newVla) - // this.fList = val; - // if (this.fList) { - // this.getList() - // } + checkStatus(newValue) { + console.log(565658) + if (newValue === "1") { + this.updateData(this.proResult, this.conclusion); + } }, - lastDesc(newVal) { - this.form.desc = newVal; // 鏇存柊 form.desc - console.log(newVal, 666); + projectList: { + immediate: true, + deep: true, + handler(newVal) { + console.log("鏀跺埌鐨勯」鐩暟鎹�:", newVal); + // 浣犲彲浠ュ湪杩欓噷澶勭悊鏁版嵁锛屾瘮濡備繚瀛樺埌 data 鎴栧仛閫昏緫鍒ゆ柇 + if (newVal && newVal.length > 0) { + const firstProject = newVal[0]; // 浣犱篃鍙互閬嶅巻鎵�鏈夐」鐩紝鐪嬩綘涓氬姟闇�姹� + this.queryParams.proId = firstProject.proId; // 鍋囪椤圭洰涓彨 id + // this.queryParams.proName = firstProject.proName; + this.proName = firstProject.proName + } + }, }, }, - mounted() {}, + mounted() { }, - created() {}, + created() { }, methods: { - getList(row, date) { - let data = { - // proId: fList.proId, - // ruleStr: fList.proResult, - }; - getlist(data).then((res) => { - this.dataList = res.rows; - this.$nextTick(() => { - /* this.dataList.forEach((item) => { - this.fList.rulesList.forEach((item1) => { - if (item.aid === item1.aid) { - this.$refs.multipleTable.toggleRowSelection(item, true); - } - }); - }); */ - }); - }); - }, - /* getList(row, date) { - if (row.proId) { - let fList = row; - // if (this.fList.proResult == "") { - let data = { - // proId: fList.proId, - // ruleStr: fList.proResult, - }; - getlist(data).then((res) => { - this.dataList = res.rows; - - this.$nextTick(() => { - this.dataList.forEach((item) => { - this.fList.rulesList.forEach((item1) => { - if (item.aid == item1.aid) { - this.$refs.multipleTable.toggleRowSelection(item, true); - } - }); - }); - }); - }); - // }else{ - // let data = { - // proId: this.fList.proId, - // bingzhong: this.queryParams.bingzhong, - // ruleStr: this.fList.proResult, - // } - // getlistByRuleStr(data).then(res => { - // this.dataList = res.rows - // this.$nextTick(() => { - // this.dataList.forEach(item => { - // this.fList.rulesList.forEach(item1 => { - // if (item.aid == item1.aid) { - // this.$refs.multipleTable.toggleRowSelection(item, true); - // } - // }) - // }) - // }) - - // }) - // } - } else { - let data = { - // proId: row, - }; - getlist(data).then((res) => { - this.dataList = res.rows; - console.log(res,888); - - // this.$nextTick(() => { - // this.dataList.forEach(item => { - // this.fList.rulesList.forEach(item1 => { - // if (item.aid == item1.aid) { - // this.$refs.multipleTable.toggleRowSelection(item, true); - // } - // }) - // }) - // }) - }); - } - }, */ - handleQuery() { - let data = { - proId: this.fList.proId, - bingzhong: this.queryParams.bingzhong, - bzPinyin: this.queryParams.bzPinyin, - }; - getlist(data).then((res) => { - this.dataList = res.rows; - this.$nextTick(() => { - this.dataList.forEach((item) => { - this.fList.rulesList.forEach((item1) => { - if (item.aid == item1.aid) { - this.$refs.multipleTable.toggleRowSelection(item, true); - } - }); - }); - }); - }); - }, - handleSelectionChange(selection) { - console.log(selection[0].yxbx,123); - - this.list = []; - this.list = selection; - this.yxbx = selection[0].yxbx - - // this.form.desc = ""; - this.list.forEach((element) => { - if (element.bingzhong) { - this.form.desc += element.bingzhong + ","; - } else { - this.form.desc += element.ruleStr + ","; + async getList() { + try { + this.loading = true; // 娣诲姞鍔犺浇鐘舵�� + const res = await getlist(this.queryParams); + this.dataList = res.data.rows; + if (res.data.total) { + this.total = res.data.total; } - }); + this.updateData(this.proResult, this.conclusion); + + // 濡傛灉闇�瑕侀�変腑鎿嶄綔锛屽皢鍏跺皝瑁呬负鐙珛鏂规硶 + await this.handleAutoSelection(); + } catch (error) { + console.error("鑾峰彇鏁版嵁澶辫触:", error); + this.$message.error("鑾峰彇鏁版嵁澶辫触"); + } finally { + this.loading = false; + } }, - /* handleSelectionChange(selection) { - // 褰撳墠閫変腑鐨勯」 - const newSelection = selection; + // 灏佽閫変腑閫昏緫 + async handleAutoSelection() { + if (!this.fList?.rulesList?.length) return; - // 1. 澶勭悊鍙栨秷閫変腑鐨勯」 - const removedItems = this.selectedItems.filter( - (item) => !newSelection.includes(item) - ); - - // 浠� form.desc 涓Щ闄ゅ彇娑堥�変腑鐨勬暟鎹� - removedItems.forEach((item) => { - const itemToRemove = item.bingzhong || item.ruleStr; - this.form.desc = this.form.desc.replace( - new RegExp(itemToRemove + ",?", "g"), // 浣跨敤姝e垯纭繚绉婚櫎鎵�鏈夐噸澶嶉」 - "" + await this.$nextTick(); + this.dataList.forEach((item) => { + const shouldSelect = this.fList.rulesList.some( + (rule) => rule.aid === item.aid ); - }); - - // 2. 鏇存柊宸查�変腑鐨勬暟鎹垪琛� - this.selectedItems = newSelection; - - // 3. 娣诲姞鏂伴�変腑鐨勯」鍒� form.desc - newSelection.forEach((element) => { - const itemToAdd = element.bingzhong || element.ruleStr; - if (!this.form.desc.includes(itemToAdd)) { - this.form.desc += itemToAdd + ","; + if (shouldSelect) { + this.$refs.multipleTable?.toggleRowSelection(item, true); } }); - }, */ - handleOk() { - this.open = false; - if (this.form.desc) { - // this.$emit("add", this.form.desc, this.list); - this.$emit("add", this.form.desc,this.yxbx); - // this.lastDesc = this.form.desc; + }, + + handleQuery() { + if (this.searchDebounce) clearTimeout(this.searchDebounce); + + this.searchDebounce = setTimeout(() => { + this.queryParams.pageNum = 1; // 閲嶇疆椤电爜 + this.getList(); + }, 300); + }, + + updateData(proResult, conclusion) { + console.log(proResult, conclusion, 5658) + if (this.checkStatus == 1) { + + this.form.jcsj = proResult; // 鏇存柊妫�鏌ユ墍瑙� + this.form.desc = conclusion; // 鏇存柊妫�鏌ョ粨璁� + } else { + this.form.desc = ""; + this.form.jcsj = ""; } - // this.form.desc = ""; + + if (this.list.length != 0) { + let desc = "" + desc += this.list + .map((item) => item.bingzhong || item.ruleStr) + .filter(Boolean) + .join(","); + let jcsj = "" + jcsj += this.list + .map((item) => item.yxbx) + .filter(Boolean) + .join(","); + this.form.jcsj = this.form.jcsj + jcsj; // 鏇存柊妫�鏌ユ墍瑙� + this.form.desc = this.form.desc + desc; + } + }, + + handleSelectionChange(selection) { + this.list = selection; + this.updateFormContent(selection); + }, + + updateFormContent(selection) { + // if (!selection.length) return; + this.updateData(this.proResult, this.conclusion); + // 濡傛灉澶勪簬妫�鏌ョ姸鎬侊紝浣跨敤浼犲叆鐨勫�� + // if (this.checkStatus === "1") { + // this.updateData(this.proResult, this.conclusion); + // return; + // } + + // 閲嶇疆琛ㄥ崟鍐呭 + // this.form.desc = ""; + // this.form.jcsj = ""; + // console.log(22222); + // // 浣跨敤map鍜宩oin鏇夸唬forEach鍜屽瓧绗︿覆鎷兼帴 + // this.form.desc = selection + // .map((item) => item.bingzhong || item.ruleStr) + // .filter(Boolean) + // .join(","); + + // this.form.jcsj = selection + // .map((item) => item.yxbx) + // .filter(Boolean) + // .join(","); + }, + + handleOk() { + if (!this.form.desc && !this.form.jcsj) { + this.$message.warning("璇烽�夋嫨鏁版嵁"); + return; + } + + try { + this.$emit("add", this.form.desc, this.form.jcsj); + this.resetForm(); + this.open = false; + } catch (error) { + console.error("澶勭悊鏁版嵁澶辫触:", error); + this.$message.error("鎿嶄綔澶辫触"); + } + }, + + resetForm() { + this.form.desc = ""; + this.form.jcsj = ""; + this.list = []; + if (this.$refs.multipleTable) { + this.$refs.multipleTable.clearSelection(); + } + }, + callcolos() { + this.open = false; + } + }, + computed: { + isCheckMode() { + return this.checkStatus === "1"; + }, + + hasSelectedItems() { + return this.list.length > 0; }, }, }; </script> - -<style scoped></style> - \ No newline at end of file + +<style scoped> +.el-dialog__body { + padding: 0px 20px; +} + +::v-deep .el-dialog__header { + padding: 0px !important; + padding-bottom: 0px !important; +} + +::v-deep .el-dialog__footer { + padding: 0 !important; + padding-bottom: 40px !important; +} + +.jianc { + width: 100%; + height: 600px; + padding-top: 40px +} +</style> \ No newline at end of file -- Gitblit v1.8.0