From 2f0e1ee5a74344f6a108df4559beed0423b9639d Mon Sep 17 00:00:00 2001 From: lkk <364857242@qq.com> Date: 星期二, 08 四月 2025 17:50:19 +0800 Subject: [PATCH] 1 --- src/components/public/index.vue | 486 +++++++++++++++++++++++++++++++++-------------------- 1 files changed, 304 insertions(+), 182 deletions(-) diff --git a/src/components/public/index.vue b/src/components/public/index.vue index 897be38..8c9a710 100644 --- a/src/components/public/index.vue +++ b/src/components/public/index.vue @@ -1,194 +1,316 @@ <template> - <div> - <el-dialog :title="title" :visible.sync="open" width="600px" 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"> - <el-input v-model="queryParams.bingzhong" placeholder="璇疯緭鍏ョ畝绉�" clearable - @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="bingzhong" /> - </el-table> - <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> - <el-button type="primary" @click="handleOk">纭� 瀹�</el-button> - </span> - </el-dialog> + <div> + <el-dialog + :title="title" + :visible.sync="open" + width="1000px" + 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"> + <el-input + v-model="queryParams.bingzhong" + placeholder="璇疯緭鍏ョ畝绉�" + clearable + @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-item> + <h3 style="margin-left: 160px;">宸查�夐」鐩�</h3> + </el-form-item> + + </el-form> + <div style="display: flex; width: 100%"> + <div style="width: 50%; margin-right: 30px"> + <el-table + :data="dataList" + ref="multipleTable" + v-loading="loading" + @selection-change="handleSelectionChange" + border + height="420px" + > + <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="ruleStr" /> + <el-table-column label="妫�鏌ユ墍瑙�" align="center" prop="yxbx" /> + </el-table> + <div class="pag"> + <div class="pag1" style="margin-left: 600px"> + <pagination + small + v-show="total > 0" + :total="total" + :page.sync="queryParams.pageNum" + :limit.sync="queryParams.pageSize" + @pagination="getList" + /> + </div> + </div> + </div> - </div> + <div style="width: 100%; height: 610px"> + <!-- <h3 style="margin-top: -30px;">宸查�夐」鐩�</h3> --> + <el-form + :model="form" + ref="queryForm" + size="small" + + label-width="68px" + > + <!-- :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: 8}" + style="width: 380px" + /> + </el-form-item> + <el-form-item label="妫�鏌ョ粨璁�" prop="conclusion"> + <el-input + v-model="form.desc" + clearable + type="textarea" + :autosize="{ minRows: 8 }" + style="width: 380px" + /> + </el-form-item> + </el-form> + </div> + </div> + + <span slot="footer" class="dialog-footer" style="margin-top: -120px"> + <el-button @click="open = false">鍙� 娑�</el-button> + <el-button type="primary" @click="handleOk">纭� 瀹�</el-button> + </span> + </el-dialog> + </div> </template> <script> -import { - getlist, getlistByRuleStr -} from "@/api/doctor/check"; +import { getlist, getlistByRuleStr } from "@/api/doctor/check"; +import { getYxJcXxJg } from "@/api/picture/picture"; export default { - name: 'Public', - - props: { - row: { - type: Object, - } - + name: "Public", + props: { + checkStatus: { + type: String, + default: "0", + validator: value => ["0", "1"].includes(value) }, - data() { - return { - open: false, - // 寮瑰嚭灞傛爣棰� - title: "", - dataList: [], - // 閬僵灞� - loading: false, - form: { - desc: "" - }, - queryParams: { - bingzhong: "", - bzPinyin: "", - }, - list: [], - fList: {} - }; + proResult: { + type: String, + default: '' }, - watch: { - 'row'(val, newVla) { - // console.log(val,newVla) - this.fList = val - console.log(this.fList); - // if (this.fList) { - // this.getList() - // } - } - }, - mounted() { - - }, - - created() { - - }, - methods: { - 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 - // 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) { - this.list = [] - this.list = selection - this.form.desc = "" - this.list.forEach(element => { - this.form.desc += element.bingzhong + "," - }); - }, - handleOk() { - this.open = false - if (this.form.desc) { - this.$emit('add', this.form.desc, this.list); - } - this.form.desc = "" - } + conclusion: { + type: String, + default: '' } -} + }, + data() { + return { + open: false, + // 寮瑰嚭灞傛爣棰� + title: "", + yxbx: "", + // lastDesc: "", + total: 0, + dataList: [], + // 閬僵灞� + loading: false, + form: { + desc: "", + jcsj: "", + }, + queryParams: { + bingzhong: "", + bzPinyin: "", + pageNum: 1, + pageSize: 10, + }, + list: [], + fList: {}, + selectedItems: [], + searchDebounce: null, + }; + }, + watch: { + checkStatus(newValue) { + console.log( newValue,9988); + if (newValue === "1") { + this.updateData(this.proResult, this.conclusion); + } + }, + }, + mounted() {}, + + created() {}, + methods: { + async getList() { + try { + this.loading = true; // 娣诲姞鍔犺浇鐘舵�� + const res = await getlist(this.queryParams); + this.dataList = res.rows; + this.total = res.total; + + // 濡傛灉闇�瑕侀�変腑鎿嶄綔锛屽皢鍏跺皝瑁呬负鐙珛鏂规硶 + await this.handleAutoSelection(); + } catch (error) { + console.error('鑾峰彇鏁版嵁澶辫触:', error); + this.$message.error('鑾峰彇鏁版嵁澶辫触'); + } finally { + this.loading = false; + } + }, + + // 灏佽閫変腑閫昏緫 + async handleAutoSelection() { + if (!this.fList?.rulesList?.length) return; + + await this.$nextTick(); + this.dataList.forEach(item => { + const shouldSelect = this.fList.rulesList.some(rule => rule.aid === item.aid); + if (shouldSelect) { + this.$refs.multipleTable?.toggleRowSelection(item, true); + } + }); + }, + + handleQuery() { + if (this.searchDebounce) clearTimeout(this.searchDebounce); + + this.searchDebounce = setTimeout(() => { + this.queryParams.pageNum = 1; // 閲嶇疆椤电爜 + this.getList(); + }, 300); + }, + + updateData(proResult, conclusion) { + if (this.checkStatus === "1") { + this.form.jcsj = proResult; // 鏇存柊妫�鏌ユ墍瑙� + this.form.desc = conclusion; // 鏇存柊妫�鏌ョ粨璁� + // console.log(proResult, conclusion); + } + }, + + handleSelectionChange(selection) { + this.list = selection; + this.updateFormContent(selection); + }, + + updateFormContent(selection) { + if (!selection.length) return; + + // 濡傛灉澶勪簬妫�鏌ョ姸鎬侊紝浣跨敤浼犲叆鐨勫�� + if (this.checkStatus === "1") { + this.updateData(this.proResult, this.conclusion); + return; + } + + // 閲嶇疆琛ㄥ崟鍐呭 + this.form.desc = ''; + this.form.jcsj = ''; + + // 浣跨敤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(); + } + }, + }, + computed: { + isCheckMode() { + return this.checkStatus === "1"; + }, + + hasSelectedItems() { + return this.list.length > 0; + } + } +}; </script> -<style scoped></style> +<style scoped> +.el-dialog__body{ + padding: 10px 20px; +} +::v-deep .el-dialog__footer { + padding: 0 !important; + padding-bottom: 40px !important; +} +</style> \ No newline at end of file -- Gitblit v1.8.0