From 82fff5df02f44d1f36c3b9052870bac2b24bd47b Mon Sep 17 00:00:00 2001 From: zouyu <2723363702@qq.com> Date: 星期六, 26 八月 2023 17:54:00 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.110.209:9001/r/lims-before --- src/api/util/requestUtil.js | 8 src/views/basicData/index.vue | 51 -- src/views/experiment/inspectionApplication/index.vue | 210 +++++----- src/views/standardLibrary/index.vue | 54 -- src/api/laboratory/organizational.js | 40 ++ src/views/laboratory/organizational/index.vue | 216 ++++++++++- src/views/laboratory/personnel/index.vue | 435 ++++++++++++++++++----- src/api/experiment/planAssignments.js | 16 8 files changed, 708 insertions(+), 322 deletions(-) diff --git a/src/api/experiment/planAssignments.js b/src/api/experiment/planAssignments.js index e2bae08..51f20e3 100644 --- a/src/api/experiment/planAssignments.js +++ b/src/api/experiment/planAssignments.js @@ -55,3 +55,19 @@ params }) } +//鍘熸潗鏂欐楠屽垪琛� +export function YANcailiso(params) { + return request({ + url: '/raw-material/selectAll', + method: 'get', + params + }) +} +//鐗堟湰鍙� +export function chooseVer(params) { + return request({ + url: '/inspection/chooseVer', + method: 'get', + params + }) +} diff --git a/src/api/laboratory/organizational.js b/src/api/laboratory/organizational.js index a88b77f..bec30c9 100644 --- a/src/api/laboratory/organizational.js +++ b/src/api/laboratory/organizational.js @@ -2,10 +2,50 @@ const Api = { getOrganizational: "/organizational/list", // 鍥涚骇鏍� + getTableInitialization: "/organizational/table", // 琛ㄦ牸鏁版嵁鎺ュ彛 + organizationalAdd: "/organizational/add", // 娣诲姞閮ㄩ棬 + organizationalUpdate: "/organizational/add", // 淇敼閮ㄩ棬 + organizationalDelete: "/organizational/delete", // 鍒犻櫎閮ㄩ棬 } export function getOrganizationalApi() { return request({ url: Api.getOrganizational, method: 'get' }) +} + +export function getTableInitializationApi(departmentId) { + return request({ + url: Api.getTableInitialization, + method: 'get', + params: { + departmentId + } + }) +} + +export function organizationalAddApi(formData){ + return request({ + url: Api.organizationalAdd, + method: 'post', + data: formData + }) +} + +export function organizationalUpdateApi(formData){ + return request({ + url: Api.organizationalUpdate + '?id=' + formData.id, + method: 'put', + data: formData + }) +} + +export function organizationalDeleteApi(id){ + return request({ + url: Api.organizationalDelete, + method: 'delete', + params: { + ids: id.toString() + } + }) } \ No newline at end of file diff --git a/src/api/util/requestUtil.js b/src/api/util/requestUtil.js index 3055a2f..df22c02 100644 --- a/src/api/util/requestUtil.js +++ b/src/api/util/requestUtil.js @@ -16,6 +16,14 @@ }) } +export function put(path, data) { + return request({ + url: path, + method: 'put', + data + }) +} + export function wpost(path, params) { return request({ url: path, diff --git a/src/views/basicData/index.vue b/src/views/basicData/index.vue index 952955e..e47537f 100644 --- a/src/views/basicData/index.vue +++ b/src/views/basicData/index.vue @@ -143,6 +143,7 @@ ref="multipleTable" @select="selectTr" @select-all="selectAll" + @selection-change="handleSelectionChange" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" > <el-table-column type="selection" label="搴忓彿"> </el-table-column> @@ -344,20 +345,6 @@ this.isAllSelect = !this.isAllSelect; let data = this.tableData; this.toggleSelect(data, this.isAllSelect, "all"); - // 鑷畾涔� - if (this.isAllSelect) { - val.forEach((i) => { - if (i.id !== undefined) { - this.deleteList.push(i.id); - } else { - i.children.forEach((c) => { - this.deleteList.push(c.id); - }); - } - }); - } else { - this.deleteList.splice(0, this.deleteList.length); - } }, //閫夋嫨鏌愯 selectTr(selection, row) { @@ -366,33 +353,6 @@ this.isAllSelect = row.isChecked; this.toggleSelect(row, row.isChecked, "tr"); }); - - if (row.isChecked === true) { - if (row.children !== undefined) { - row.children.forEach((i) => { - this.deleteList.push(i.id); - }); - } else { - this.deleteList.push(row.id); - } - } else if (row.isChecked === false) { - if (row.children !== undefined) { - row.children.forEach((i) => { - this.deleteList.findIndex((c, index) => { - if (c === i.id) { - this.deleteList.splice(index, 1); - return; - } - }); - }); - } - this.deleteList.findIndex((c, index) => { - if (c === row.id) { - this.deleteList.splice(index, 1); - return; - } - }); - } }, //閫掑綊瀛愮骇 toggleSelect(data, flag, type) { @@ -426,6 +386,15 @@ } }); }, + handleSelectionChange(val) { + this.deleteList = [] + val.forEach((v) => { + if(v.id !== undefined) { + this.deleteList.push(v.id) + } + }) + console.log(`output->this.deleteList`,this.deleteList) + }, // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆 缁撴潫 deleteListClick() { deleteListApi(this.deleteList).then((res) => { diff --git a/src/views/experiment/inspectionApplication/index.vue b/src/views/experiment/inspectionApplication/index.vue index e53dd3a..e6f5023 100644 --- a/src/views/experiment/inspectionApplication/index.vue +++ b/src/views/experiment/inspectionApplication/index.vue @@ -252,44 +252,44 @@ <el-form :model="commisionSelection" ref="commisionTable" class="checkTypeForm" label-position="top" label-width="200px" size="mini"> <el-row :gutter="100"> <el-col :span="10"> - <el-form-item label="鏉ユ枡鏃ユ湡锛�"> - <el-input style="width: 300px" type="text" :value="commisionSelection.formTime" placeholder="璇疯緭鍏ユ潵鏂欐棩鏈�" autocomplete="off" /> + <el-form-item label="濮旀墭缂栧彿"> + <el-input style="width: 300px" type="text" :value="commisionSelection.entrust_coding" placeholder="璇疯緭鍏ユ潵鏂欐棩鏈�" autocomplete="off" /> </el-form-item> </el-col> <el-col :span="10"> - <el-form-item label="渚涘簲鍟嗗悕绉帮細"> - <el-input style="width: 300px" type="text" :value="commisionSelection.supplier" placeholder="璇疯緭鍏ュ鎵樺崟浣�" autocomplete="off" /> + <el-form-item label="濮旀墭鍗曚綅"> + <el-input style="width: 300px" type="text" :value="commisionSelection.entrusted" placeholder="璇疯緭鍏ュ鎵樺崟浣�" autocomplete="off" /> </el-form-item> </el-col> </el-row> <el-row :gutter="100"> <el-col :span="10"> - <el-form-item label="濮旀墭缂栧彿锛�"> - <el-input style="width: 300px" type="text" :value="commisionSelection.mcode" placeholder="璇疯緭鍏ユ牱鍝佺紪鍙�" autocomplete="off" /> + <el-form-item label="鏍峰搧缂栧彿"> + <el-input style="width: 300px" type="text" :value="commisionSelection.samples_number" placeholder="璇疯緭鍏ユ牱鍝佺紪鍙�" autocomplete="off" /> </el-form-item> </el-col> <el-col :span="10"> - <el-form-item label="濮旀墭鍚嶇О锛�"> - <el-input style="width: 300px" type="text" :value="commisionSelection.name" placeholder="璇疯緭鍏ユ牱鍝佸悕绉�" autocomplete="off" /> + <el-form-item label="鏍峰搧鍚嶇О"> + <el-input style="width: 300px" type="text" :value="commisionSelection.sample_name" placeholder="璇疯緭鍏ユ牱鍝佸悕绉�" autocomplete="off" /> </el-form-item> </el-col> </el-row> <el-row :gutter="100"> <el-col :span="10"> <el-form-item label="瑙勬牸鍨嬪彿锛�"> - <el-input style="width: 300px" type="text" :value="commisionSelection.specifications" placeholder="璇疯緭鍏ュ瀷鍙疯鏍�" autocomplete="off" /> + <el-input style="width: 300px" type="text" :value="commisionSelection.specifications_models" placeholder="璇疯緭鍏ュ瀷鍙疯鏍�" autocomplete="off" /> </el-form-item> </el-col> <el-col :span="10"> - <el-form-item label="鍗曚綅锛�"> - <el-input style="width: 300px" type="text" :value="commisionSelection.unit" placeholder="璇疯緭鍏ュ崟浣�" autocomplete="off" /> + <el-form-item label="閫佽揪鏃堕棿"> + <el-input style="width: 300px" type="text" :value="commisionSelection.dateSurvey" placeholder="璇疯緭鍏ュ崟浣�" autocomplete="off" /> </el-form-item> </el-col> </el-row> <el-row :gutter="100"> <el-col :span="10"> - <el-form-item label="鏁伴噺锛�"> - <el-input style="width: 300px" type="text" :value="commisionSelection.num" placeholder="璇疯緭鍏ユ暟閲�" autocomplete="off" /> + <el-form-item label="瀹屾垚鏈熼檺"> + <el-input style="width: 300px" type="text" :value="commisionSelection.completionDeadline" placeholder="璇疯緭鍏ユ暟閲�" autocomplete="off" /> </el-form-item> </el-col> <el-col :span="10"> @@ -379,21 +379,21 @@ <el-dialog title="鏍囧噯搴�" :visible.sync="Standardframe" - width="48%" - - > - <!-- <el-form :model="form"> - <el-form-item label="璇烽�夋嫨瀹℃牳缁撴灉:" :label-width="formLabelWidth"> - </el-form-item> - </el-form> --> - - <!-- <div slot="footer" class="dialog-footer"> --> + width="48%"> + <el-card> + <template slot-scope="scope" > + <span>鐗堟湰閫夋嫨锛�</span> + <el-select v-model="commisionTable" size="small" slot="append" style="width: 220px;"> + <el-option v-for="item in BANben" :key="item.id" :label="item.name" :value="item.name"></el-option> + </el-select> + </template> + </el-card> <el-table :data="tableData" style="width: 100%; margin-bottom: 20px" row-key="name" border - height="calc(100vh - 250px)" + default-expand-all ref="multipleTable" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" @@ -445,7 +445,11 @@ </template> </el-table-column> </el-table> - <!-- </div> --> + <span slot="footer" class="dialog-footer"> + <el-button @click="Standardframe = false">鍙� 娑�</el-button> + <el-button type="primary" @click="Standardframe = false">纭� 瀹�</el-button> + </span> + </el-dialog> <!-- 鍘熸潗鏂欐楠屾ā鎬佹 --> @@ -461,11 +465,10 @@ :header-cell-style="{border:'0px',background:'#f5f7fa',color:'#606266',boxShadow: 'inset 0 1px 0 #ebeef5',textAlign: 'center'}" :data="rawMaterialTable" style="width: 100%" - @selection-change="handleSelectionChange" + @selection-change="handleSelectionChange_0" > - <el-table-column + <el-table-column type="selection" - label="" min-width="10%" /> <el-table-column @@ -474,7 +477,7 @@ min-width="8%" /> <el-table-column - prop="dateSurvey" + prop="createTime" label="鏉ユ枡鏃ユ湡" min-width="8%" /> @@ -519,12 +522,12 @@ min-width="8%" /> <el-table-column - prop="createTime" + prop="dateSurvey" label="妫�楠屾棩鏈�" min-width="8%" /> <el-table-column - prop="state" + prop="condition" label="鐘舵��" min-width="8%" > @@ -556,50 +559,32 @@ @selection-change="handleSelectionChange" style="width: 100%" > - <el-table-column - type="selection" - min-width="10%" - /> - <el-table-column - type="index" - label="搴忓彿" - min-width="10%" - /> - <el-table-column - prop="formTime" - label="濮旀墭bian'ha" - min-width="10%" - /> - <el-table-column - prop="supplier" - label="渚涘簲鍟嗗悕绉�" - min-width="12%" - /> - <el-table-column - prop="mcode" - label="鏉愭枡缂栫爜" - min-width="8%" - /> - <el-table-column - prop="specifications" - label="瑙勬牸鍨嬪彿" - min-width="8%" - /> - <el-table-column - prop="unit" - label="鍗曚綅" - min-width="12%" - /> - <el-table-column - prop="num" - label="鏁伴噺" - min-width="8%" - /> - <el-table-column - prop="checkdate_" - label="妫�楠屾棩鏈�" - min-width="8%" - /> + <el-table-column type="selection" min-width="10%" /> + <el-table-column type="index" label="搴忓彿" min-width="10%" /> + <el-table-column prop="entrust_coding" label="濮旀墭缂栧彿" min-width="10%" /> + <el-table-column prop="entrusted" label="濮旀墭鍗曚綅" min-width="12%" /> + <el-table-column prop="samples_number" label="鏍峰搧缂栧彿" min-width="8%" /> + <el-table-column prop="sample_name" label="鏍峰搧鍚嶇О" min-width="8%" /> + <el-table-column prop="specifications_models" label="瑙勬牸鍨嬪彿" min-width="12%" /> + <el-table-column prop="dateSurvey" label="閫佽揪鏃堕棿" min-width="8%" /> + <el-table-column prop="completionDeadline" label="瀹屾垚鏈熼檺" min-width="8%" /> + <el-table-column prop="contacts" label="濮旀墭缂栧埗浜�" min-width="8%" /> + <el-table-column prop="inspectionTime" label="妫�楠屾棩鏈�" min-width="8%" /> + <el-table-column prop="inspection_status" label="鐘舵��" min-width="8%"> + <template slot-scope="scope"> + <div v-if="scope.row.inspection_status === 1"> + <span style="color: green;">宸叉娴�</span> + </div> + <div v-else> + <span style="color: red;">寰呮娴�</span> + </div> + </template> + </el-table-column> + <el-table-column label="鎿嶄綔" min-width="8%"> + <template slot-scope="scope"> + <el-button type="text" size="small">鍒犻櫎</el-button> + </template> + </el-table-column> </el-table> <span slot="footer" class="dialog-footer"> <el-button @click="commisionVisible = false">鍙� 娑�</el-button> @@ -615,7 +600,7 @@ </template> <script> - import { selectInspectsList, selectAll, addInspect,getCommisionList} from '@/api/experiment/planAssignments' + import { selectInspectsList, selectAll, addInspect,getCommisionList,YANcailiso,chooseVer} from '@/api/experiment/planAssignments' export default { data() { return { @@ -625,34 +610,11 @@ type: '', state: '', }, + valu:{}, icode:'', inspectionTable: [], rawMaterialTable: [], - commisionTable: [{ - specifications_models: "GGXH-AAAAA", - inspectionTime: "2023-08-03", - id: 2, - samples_number: 0, - dateSurvey: "2023-08-03", - entrusted: "闃块噷宸村反", - completionDeadline: "2023-08-03", - contacts: "灏忛粦", - entrust_coding: "SL20230803000003", - sample_name: "鍙戝姩鏈�", - inspection_status: 1 - },{ - specifications_models: "GGXH-AAAAA", - inspectionTime: "2023-08-03", - id: 2, - samples_number: 0, - dateSurvey: "2023-08-03", - entrusted: "闃块噷宸村反", - completionDeadline: "2023-08-03", - contacts: "灏忛粦", - entrust_coding: "SL20230803000003", - sample_name: "鍙戝姩鏈�", - inspection_status: 1 - }], + commisionTable: [], finishedTable: { deliverydate: '', supplier: '', @@ -709,7 +671,10 @@ commisionVisible: false, tmp: '', Standardframe: false, - tableData: [] + tableData: [], + tableRow:{}, + BANben:[], + select_1: [] } }, watch: { @@ -735,11 +700,27 @@ this.$router.push({name:'Viewdetails',query: {id:row.id}}); this.selectInspectsList() }, + //鐗堟湰搴� + async chooseVer() { + const res = await chooseVer ({ + mcode:this.commisionTable.entrust_coding, + name:this.commisionTable.entrusted, + scifications:this.commisionTable.specifications_models + }) + console.log(res); + this.BANben = res.data.row + }, //濮旀墭妫�楠� async getCommisionList() { const res = await getCommisionList({pageNo:1,pageSize:10 }) + console.log(res); this.commisionTable = res.data - console.log(this.commisionTable); + }, + //鍘熸潗鏂� + async selecYANcailisotAllAPI() { + const res = await YANcailiso({pageNo:1,pageSize:10 }) + console.log(res); + this.rawMaterialTable = res.data.row }, async selectInspectsList() { // 鑾峰彇鍒嗛〉鍒楄〃 @@ -833,9 +814,10 @@ // this.$router.push({ name: 'ReportForInspection' }); }else if(this.type === 1){ this.commisionVisible = true - getCommisionList({pageNo:1,pageSize:10}).then(res=>{ - this.commisionTable = res.data - }) + getCnList({pageNo:1,pageSize:10}).then(res=>{ + // consommisioole.log(res); + this.commisionTable = res.data.row + }) } },100) }, @@ -902,7 +884,25 @@ }, //纭畾璺宠浆 QUEding(){ + // this.tableRow = a this.Standardframe = true + chooseVer({mcode:this.select_1[0].materialCoding, + name:this.select_1[0].materialName, + scifications:this.select_1[0].specificationsModels}).then(res => { + this.BANben = res.data.row + console.log(this.BANben); + }) + + }, + handleSelectionChange_0(val){ + this.select_1 = [] + val.forEach(v => { + let obj = {} + obj.materialCoding = v.materialCoding + obj.materialName = v.materialName + obj.specificationsModels = v.specificationsModels + this.select_1.push(obj) + }) } } } diff --git a/src/views/laboratory/organizational/index.vue b/src/views/laboratory/organizational/index.vue index b25fa6a..b44012b 100644 --- a/src/views/laboratory/organizational/index.vue +++ b/src/views/laboratory/organizational/index.vue @@ -23,9 +23,15 @@ type="primary" size="small" icon="el-icon-circle-plus-outline" + @click="dialogVisible = true" >鏂板</el-button > - <el-button size="small" icon="el-icon-delete-solid">鍒犻櫎</el-button> + <el-button + size="small" + icon="el-icon-delete-solid" + @click="listDeleteClick" + >鍒犻櫎</el-button + > </div> </div> <div class="table-main-div"> @@ -39,27 +45,84 @@ @selection-change="handleSelectionChange" > <el-table-column type="selection" width="55"> </el-table-column> - <el-table-column label="鏃ユ湡" width="120"> - <template slot-scope="scope">{{ scope.row.date }}</template> - </el-table-column> - <el-table-column prop="name" label="濮撳悕" width="120"> - </el-table-column> - <el-table-column prop="address" label="鍦板潃" show-overflow-tooltip> + <el-table-column + label="搴忓彿" + type="index" + width="70" + ></el-table-column> + <el-table-column prop="department" label="閮ㄩ棬"> </el-table-column> + <el-table-column label="鎿嶄綔"> + <template scope="scope"> + <el-button type="text" size="mini" @click="updateClick(scope)" + >缂栬緫</el-button + > + <el-button type="text" size="mini" @click="deleteClick(scope)" + >鍒犻櫎</el-button + > + </template> </el-table-column> </el-table> </div> </div> + <el-dialog + :title="isUpdate ? '鏇存柊閮ㄩ棬鍚嶇О' : '鏂板閮ㄩ棬'" + :visible.sync="dialogVisible" + width="30%" + > + <el-form + :model="formData" + :rules="rules" + ref="ruleForm" + class="elFormClass" + > + <el-form-item label="涓婄骇閮ㄩ棬锛�" prop="name" style="padding-left: 10px"> + <el-input + v-model="treeNodeData.department" + :disabled="true" + style="width: 81.3%" + > + </el-input> + </el-form-item> + <el-form-item + label="閮ㄩ棬鍚嶇О锛�" + prop="department" + style="padding-top: 20px" + > + <el-input + placeholder="璇疯緭鍏ラ儴闂ㄥ悕绉�" + v-model="formData.department" + clearable + style="width: 80%" + > + </el-input> + </el-form-item> + </el-form> + <span slot="footer" class="dialog-footer"> + <el-button @click="dialogVisible = false">鍙� 娑�</el-button> + <el-button type="primary" @click="saveForm">{{ + isUpdate ? "鏇� 鏂�" : "鏂� 澧�" + }}</el-button> + </span> + </el-dialog> </div> </template> <script> -import { getOrganizationalApi } from "@/api/laboratory/organizational"; +import { + getOrganizationalApi, + getTableInitializationApi, + organizationalAddApi, + organizationalUpdateApi, + organizationalDeleteApi, +} from "@/api/laboratory/organizational"; export default { name: "Organizational", data() { return { filterText: "", + dialogVisible: false, msg: "", + isUpdate: false, data: [], // tree鏍戦粯璁ゅ�奸厤缃� defaultProps: { @@ -67,28 +130,24 @@ label: "department", id: "id", }, - tableData: [ - { - date: "2016-05-02", - name: "鐜嬪皬铏�", - address: "涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1518 寮�", - }, - { - date: "2016-05-04", - name: "鐜嬪皬铏�", - address: "涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1517 寮�", - }, - { - date: "2016-05-01", - name: "鐜嬪皬铏�", - address: "涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1519 寮�", - }, - { - date: "2016-05-03", - name: "鐜嬪皬铏�", - address: "涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1516 寮�", - }, - ], + formData: { + fatherId: "", + department: "", + }, + // 鏂板鎸夐挳閲岄潰绂佹杈撳叆妗嗘暟鎹� + disabledInputShow: "", + // 淇濆瓨鐐瑰嚮鑺傜偣鏁版嵁 + treeNodeData: {}, + // 澶氶�夊垹闄� + listDelete: [], + // 琛ㄦ牸鏁版嵁 + tableData: [], + rules: { + department: [ + { required: true, message: "璇疯緭鍏ユ椿鍔ㄥ悕绉�", trigger: "blur" }, + { min: 1, max: 25, message: "闀垮害鍦� 1 鍒� 5 涓瓧绗�", trigger: "blur" }, + ], + }, }; }, methods: { @@ -101,6 +160,13 @@ treeInitialization() { getOrganizationalApi().then((res) => { this.data = res.data; + // 鍒濆鍖栭粯璁sg鎻愮ず璺緞涓虹涓�鑺傜偣鍚嶇О + this.msg = res.data[0].department; + // 鍒濆鍖栬皟鐢ㄨ〃鏍兼帴鍙� + this.tableInitialization(res.data[0].id); + // 鍒濆鍖栦繚瀛樼涓�鑺傜偣鏁版嵁 + this.treeNodeData.department = res.data[0].department; + this.treeNodeData.id = res.data[0].id; }); }, // 鑾峰彇鏍戣矾寰� @@ -115,10 +181,14 @@ // 鐐瑰嚮鏍戣妭鐐� handleNodeClick(data, node, element) { this.getParentData(node.parent, node.data.department); - console.log(`output->this.msg`, this.msg); - console.log(`output->data`, data); - console.log(`output->node`, node); - console.log(`output->element`, element); + // 鐢变簬鐐瑰嚮绗竴鑺傜偣鏃犳硶瑙﹀彂getParentData閲岄潰鐨勫垽鏂紝鍙兘棰濆鍒ゆ柇 + if (node.data.id === 0) { + this.msg = node.data.department; + } + // 鐐瑰嚮鑺傜偣鏁版嵁瀛樺偍涓嬫潵 + this.treeNodeData = node.data; + // 鐐瑰嚮瑙﹀彂璇ュ嚱鏁帮紝鏇存柊琛ㄦ牸鏁版嵁 + this.tableInitialization(node.data.id); }, // 鏀瑰彉澶氶�夋鐘舵�� toggleSelection(rows) { @@ -132,7 +202,71 @@ }, // 鐐瑰嚮澶氶�夋浠ュ悗鐨勬搷浣� handleSelectionChange(val) { - this.multipleSelection = val; + this.listDelete = [] + val.forEach((v) => { + this.listDelete.push(v.id); + }); + }, + // 鍒濆鍖栬〃鏍兼暟鎹� + tableInitialization(departmentId) { + getTableInitializationApi(departmentId).then((res) => { + this.tableData = res.data; + }); + }, + // 鏇存柊涓庢柊澧炶〃鍗� + saveForm() { + this.formData.fatherId = this.treeNodeData.id; + this.$refs.ruleForm.validate((valid) => { + if (valid) { + if (!this.isUpdate) { + organizationalAddApi(this.formData).then((res) => { + this.$message({ + message: res.message, + type: "success", + }); + this.treeInitialization(); + this.dialogVisible = false; + }); + } else { + organizationalUpdateApi(this.formData).then((res) => { + this.$message({ + message: res.message, + type: "success", + }); + this.treeInitialization(); + this.dialogVisible = false; + }); + } + } + }); + }, + // 鐐瑰嚮缂栬緫瑙﹀彂 + updateClick(scope) { + this.dialogVisible = true; + this.isUpdate = true; + this.formData.id = scope.row.id; + this.formData.fatherId = this.treeNodeData.id; + this.formData.department = scope.row.department; + }, + // 琛ㄦ牸涓殑鍒犻櫎鎸夐挳 + deleteClick(scope) { + organizationalDeleteApi(scope.row.id).then((res) => { + this.$message({ + message: res.message, + type: "success", + }); + this.treeInitialization(); + }); + }, + // 澶撮儴澶氶�夊垹闄� + listDeleteClick() { + organizationalDeleteApi(this.listDelete).then((res) => { + this.$message({ + message: res.message, + type: "success", + }); + this.treeInitialization(); + }); }, }, mounted() { @@ -141,6 +275,15 @@ watch: { filterText(val) { this.$refs.tree.filter(val); + }, + dialogVisible: { + handler(newVal, oldVal) { + if (newVal == false) { + this.isUpdate = false; + this.formData = {}; + this.$refs.ruleForm.resetFields(); + } + }, }, }, }; @@ -187,4 +330,7 @@ font-weight: 500; color: #999999; } +.elFormClass .el-form-item__error { + padding-left: 90px; +} </style> diff --git a/src/views/laboratory/personnel/index.vue b/src/views/laboratory/personnel/index.vue index 26998b3..4259f2f 100644 --- a/src/views/laboratory/personnel/index.vue +++ b/src/views/laboratory/personnel/index.vue @@ -1,5 +1,5 @@ <template> - <div class="personnel-main "> + <div class="personnel-main"> <div class="page-header-search"> <div class="search-bar"> <el-form ref="form" :inline="true"> @@ -10,74 +10,197 @@ </el-form-item> <el-form-item> <el-button type="primary" @click="getData()">鏌ヨ</el-button> - <el-button type="primary" plain @click="resetData()">閲嶇疆</el-button> + <el-button type="primary" plain @click="resetData()" + >閲嶇疆</el-button + > <!-- <el-button type="text">楂樼骇鎼滅储<i class="el-icon-arrow-down el-icon--right" /></el-button> --> </el-form-item> </el-form> </div> <div class="serve-btn"> - <el-button type="primary" icon="el-icon-plus" @click="dialogFormVisible = true">鏂板浜哄憳</el-button> + <el-button + type="primary" + icon="el-icon-plus" + @click="dialogFormVisible = true" + >鏂板浜哄憳</el-button + > - <el-dialog title="鏂板浜哄憳" :visible.sync="dialogFormVisible" width="30%"> - <el-form :model="form" :rules="rules"> - <el-form-item label="璐﹀彿" :label-width="formLabelWidth" prop="account"> - <el-input v-model="form.account" autocomplete="off" /> + <el-dialog + :title="isUpdate == true ? '鏇存柊浜哄憳淇℃伅' : '鏂板浜哄憳'" + :visible.sync="dialogFormVisible" + width="30%" + > + <el-form :model="form" ref="form" :rules="rules"> + <el-form-item + label="璐﹀彿" + :label-width="formLabelWidth" + prop="account" + > + <el-input v-model="form.account" /> </el-form-item> <el-form-item label="骞撮緞" :label-width="formLabelWidth"> - <el-input v-model="form.age" autocomplete="off" /> + <el-input v-model="form.age" /> </el-form-item> - <el-form-item label="閭" :label-width="formLabelWidth" prop="email"> - <el-input v-model="form.email" autocomplete="off" /> + <el-form-item + label="閭" + :label-width="formLabelWidth" + prop="email" + > + <el-input v-model="form.email" /> </el-form-item> - <el-form-item label="鍚嶅瓧" :label-width="formLabelWidth" prop="name"> - <el-input v-model="form.name" autocomplete="off" /> + <el-form-item + label="鍚嶅瓧" + :label-width="formLabelWidth" + prop="name" + > + <el-input v-model="form.name" /> </el-form-item> - <el-form-item label="鐢佃瘽" :label-width="formLabelWidth" prop="phone"> - <el-input v-model="form.phone" autocomplete="off" /> + <el-form-item + label="鐢佃瘽" + :label-width="formLabelWidth" + prop="phone" + > + <el-input v-model="form.phone" /> </el-form-item> - <el-form-item label="鏉冮檺" :label-width="formLabelWidth" prop="role_id"> - <el-input v-model="form.role_id" autocomplete="off" /> + <el-form-item + label="閮ㄩ棬" + :label-width="formLabelWidth" + required + prop="organizationId" + > + <el-cascader + style="width: 100%" + :options="options" + :props="myProp" + v-model="form.organizationId" + clearable + ></el-cascader> + </el-form-item> + + <el-form-item + label="鏉冮檺" + :label-width="formLabelWidth" + prop="roleId" + > + <el-select + v-model="form.roleId" + clearable + style="100%" + placeholder="璇烽�夋嫨鏉冮檺" + > + <el-option + v-for="item in roleList" + :key="item.id" + :label="item.name" + :value="item.id" + > + </el-option> + </el-select> </el-form-item> </el-form> <div slot="footer" class="dialog-footer"> <el-button @click="dialogFormVisible = false">鍙� 娑�</el-button> - <el-button type="primary" @click="submitForm()">纭� 瀹�</el-button> + <el-button type="primary" @click="submitForm()">{{ + isUpdate == true ? "鏇� 鏂�" : "纭� 瀹�" + }}</el-button> </div> </el-dialog> </div> </div> <div class="content-main"> <div class="personner-table"> - <el-table ref="personnerlTable" :max-height="700" :cell-style="{ textAlign: 'center' }" - :header-cell-style="{ border: '0px', background: '#f5f7fa', color: '#606266', boxShadow: 'inset 0 1px 0 #ebeef5', textAlign: 'center' }" - :data="personnerlTable" style="width: 100%"> + <el-table + ref="personnerlTable" + height="calc(100vh - 240px)" + border + :cell-style="{ textAlign: 'center' }" + :header-cell-style="{ + border: '0px', + background: '#f5f7fa', + color: '#606266', + boxShadow: 'inset 0 1px 0 #ebeef5', + textAlign: 'center', + }" + @filter-change="fnFilterChangeInit" + :data="personnerlTable" + style="width: 100%" + > <el-table-column prop="username" label="瑙掕壊鍚嶇О" min-width="120" /> <el-table-column prop="roleName" label="瑙掕壊鏉冮檺" min-width="120" /> - <el-table-column prop="age" label="骞撮緞" min-width="150" /> + <el-table-column prop="age" label="骞撮緞" min-width="150"> + <template scope="scope"> + {{ + scope.row.age === "" || + scope.row.age === null || + scope.row.age == undefined + ? "---" + : scope.row.age + }} + </template> + </el-table-column> + <el-table-column prop="department" label="閮ㄩ棬" min-width="150" /> <el-table-column prop="createTime" label="鍒涘缓鏃堕棿" min-width="180" /> - <el-table-column prop="phone" label="鐢佃瘽" min-width="200" /> - <el-table-column prop="email" label="閭" min-width="200" /> - <el-table-column prop="jobState" label="鍦ㄨ亴鐘舵��" min-width="120" - :filters="[{ text: 0, value: 0 }, { text: 1, value: 1 }]" :filter-method="filterTag" - filter-placement="bottom-end"> + <el-table-column prop="phone" label="鐢佃瘽" min-width="200"> + <template scope="scope"> + {{ + scope.row.phone === "" || scope.row.phone === undefined + ? "---" + : scope.row.phone + }} + </template> + </el-table-column> + <el-table-column prop="email" label="閭" min-width="200"> + <template scope="scope"> + {{ + scope.row.email === "" || scope.row.email === undefined + ? "---" + : scope.row.email + }} + </template> + </el-table-column> + <el-table-column + prop="jobState" + label="鍦ㄨ亴鐘舵��" + min-width="120" + :filters="[ + { text: '鍦ㄨ亴', value: 1 }, + { text: '绂诲矖', value: 0 }, + ]" + column-key="status" + :filter-method="filterTag" + filter-placement="bottom-end" + > <template slot-scope="scope"> - <el-tag :type="scope.row.jobState === 0 ? 'danger' : 'success'" disable-transitions>{{ - scope.row.jobState === 0 ? '绂诲矖' : '鍦ㄨ亴' }}</el-tag> + <el-tag + :type="scope.row.jobState === 0 ? 'danger' : 'success'" + disable-transitions + >{{ scope.row.jobState === 0 ? "绂诲矖" : "鍦ㄨ亴" }}</el-tag + > </template> </el-table-column> <el-table-column label="鎿嶄綔" min-width="120"> <template slot-scope="scope"> - <el-button type="text" size="small" @click="handleClick(scope.row)">缂栬緫</el-button> - <!-- <el-button type="text" size="small">缂栬緫</el-button> --> + <el-button + type="text" + size="small" + @click="handleClick(scope.row)" + >缂栬緫</el-button + > </template> </el-table-column> </el-table> <div> <!-- 鍒嗛〉鍣� --> - <el-pagination :current-page="currentPage" :page-sizes="[100, 200, 300, 400]" :page-size="pageSize" - layout="total, sizes, prev, pager, next, jumper" :total="this.personnerlTable.length" - @size-change="handleSizeChange" @current-change="handleCurrentChange" /> + <el-pagination + :current-page="currentPage" + :page-sizes="[10, 15, 20, 25]" + :page-size="pageSize" + layout="total, sizes, prev, pager, next, jumper" + :total="total" + @size-change="handleSizeChange" + @current-change="handleCurrentChange" + /> </div> </div> </div> @@ -85,15 +208,15 @@ </template> <script> -import { get, post } from '@/api/util/requestUtil'; -import urlInfo from '../../../api/urlEnum/personnel.js' +import { get, post, put } from "@/api/util/requestUtil"; +import urlInfo from "../../../api/urlEnum/personnel.js"; +import { getOrganizationalApi } from "@/api/laboratory/organizational"; export default { data() { return { - keyword: '', - personnerlTable: [ - - ], + keyword: "", + roleList: "", + personnerlTable: [], filteredpersonnerlTable: [], currentindex: 1, currentPage: 1, // 褰撳墠椤电爜 @@ -102,108 +225,224 @@ personData: [], // 鐢ㄦ潵瀛樻斁鎺ュ彛浼犺繃鏉ョ殑浜哄憳鍒楄〃鏁版嵁 dialogFormVisible: false, form: { - account: '', - age: '', - email: '', - name: '', - phone: '', - role_id: '' + account: "", + age: "", + email: "", + name: "", + phone: "", + organizationId: "", + roleId: "", }, - formLabelWidth: '100px', + myProp: { + value: "id", + label: "department", + checkStrictly: true, //鍏佽閫夋嫨浠绘剰涓�鑺� + }, + formLabelWidth: "100px", rules: { account: [ { - required: true, message: '璇疯緭鍏ヨ处鍙�', trigger: 'blur' - } + required: true, + message: "璇疯緭鍏ヨ处鍙�", + trigger: "blur", + }, ], - name: [{ - required: true, message: '璇疯緭鍏ュ悕瀛�', trigger: 'blur' - }], + name: [ + { + required: true, + message: "璇疯緭鍏ュ悕瀛�", + trigger: "blur", + }, + ], phone: [ // { required: true, message: '璇疯緭鍏�11浣嶇數璇濆彿鐮�', trigger: 'blur' }, - { pattern: /^1[34578]\d{9}$/, message: '闈炴硶鎵嬫満鍙风爜', trigger: 'blur' } + { + pattern: /^1[3456789]\d{9}$/, + message: "闈炴硶鎵嬫満鍙风爜", + trigger: ["blur", "change"], + }, ], email: [ // { required: true, message: '璇疯緭鍏ラ偖绠卞湴鍧�', trigger: 'blur' }, - { type: 'email', message: '闈炴硶閭鍦板潃', trigger: ['blur', 'change'] } + { + type: "email", + message: "闈炴硶閭鍦板潃", + trigger: ["blur", "change"], + }, ], - role_id: [ - { required: true, message: '璇疯緭鍏ユ潈闄�(0鎴�1)', trigger: 'blur' } - - ] - } - } + organizationId: [ + { + required: true, + type: "array", + message: "璇烽�夋嫨閮ㄩ棬", + trigger: "change", + }, + ], + roleId: [ + { required: true, message: "璇疯緭鍏ユ潈闄�(0鎴�1)", trigger: "blur" }, + ], + }, + options: [], + status: "", + isUpdate: false, + }; }, mounted() { - this.getData() + this.getData(); + this.getTreeData(); }, methods: { // 姣忛〉鏉℃暟鏀瑰彉鏃惰Е鍙� 閫夋嫨涓�椤垫樉绀哄灏戣 handleSizeChange(val) { - console.log(`姣忛〉 ${val} 鏉) - this.currentPage = 1 - this.pageSize = val + console.log(`姣忛〉 ${val} 鏉); + this.currentPage = 1; + this.pageSize = val; }, - filterTag() { - console.log(11); + filterTag(value) { + this.status = ""; + this.status = value; + return true; }, // 褰撳墠椤垫敼鍙樻椂瑙﹀彂 璺宠浆鍏朵粬椤� handleCurrentChange(val) { - console.log(`褰撳墠椤�: ${val}`) - this.currentPage = val + console.log(`褰撳墠椤�: ${val}`); + this.currentPage = val; }, async getData() { let data = { pageNo: 0, - pageSize: 20, - name: this.keyword - } + pageSize: 10, + name: this.keyword, + status: this.status, + }; let res = await get(urlInfo.url.list_new_personnel, data); - this.personnerlTable=res.data.row - this.total=res.data.total + this.personnerlTable = res.data.row; + this.total = res.data.total; }, searchData() { this.filteredpersonnerlTable = this.personnerlTable.filter((item) => { - return item.username === this.keyword - } - ) - this.personnerlTable = this.filteredpersonnerlTable + return item.username === this.keyword; + }); + this.personnerlTable = this.filteredpersonnerlTable; }, resetData() { - // console.log("111111") - this.personnerlTable = this.personData - this.keyword = '' + this.personnerlTable = this.personData; + this.keyword = ""; + this.status = ""; + this.getData(); }, // 鎻愪氦鏂板浜哄憳琛ㄥ崟 submitForm() { - // Handle form submission here - // console.log(this.form); - // POST璇锋眰 this.$refs.form.validate((valid) => { if (valid) { - this.dialogFormVisible = false - axios.post('/user/add_new_personnel', this.form) - .then(response => { - console.log(response) - // this.dialogVisible = false; - }) - .catch(error => { - console.error(error) - }) + let departmentId = this.form.organizationId; + this.form.organizationId = departmentId[departmentId.length - 1]; + if (!this.isUpdate) { + post("/user/add_new_personnel", this.form).then((response) => { + this.$message({ + message: response.message, + type: "success", + }); + this.dialogFormVisible = false; + this.getData(); + }); + } else { + put("/user/update_new_personnel", this.form).then((res) => { + this.$message({ + message: res.message, + type: "success", + }); + this.dialogFormVisible = false; + this.getData(); + }); + } } else { - console.log('error submit!!') - return false + console.log("error submit!!"); + return false; } - }) + }); }, - } + // 娓呯┖Cascader绌虹櫧 + clearCascaderBlank(list) { + list.forEach((i) => { + if (i.children.length === 0) { + i.children = undefined; + } else { + this.clearCascaderBlank(i.children); + } + }); + }, + fnFilterChangeInit() { + this.personData = []; + this.getData(); + }, + /* + * @param list 鏁版嵁鍒楄〃 + * @param id 鍚庣杩斿洖鐨刬d + **/ + getParentsById(list, id) { + for (let i in list) { + if (list[i].id == id) { + return [list[i].id]; + } + if (list[i].children) { + let node = this.getParentsById(list[i].children, id); + if (node !== undefined) { + //鏌ヨ鍒版妸鐖惰妭鎶婄埗鑺傜偣鍔犲埌鏁扮粍鍓嶉潰 + node.unshift(list[i].id); + return node; + } + } + } + }, -} + handleClick(row) { + this.isUpdate = true; + this.dialogFormVisible = true; + this.form.name = row.username; + this.form.roleName = row.roleName; + this.form.phone = row.phone; + this.form.id = row.id; + this.form.email = row.email; + this.form.organizationId = this.getParentsById( + this.options, + row.departmentId + ); + this.form.roleId = row.roleName; + this.form.age = row.age; + this.form.account = row.account; + }, + getTreeData() { + getOrganizationalApi().then((res) => { + this.options = res.data[0].children; + this.clearCascaderBlank(this.options); + }); + }, + getRoleList() { + get("/user/list").then((res) => { + console.log(`output->res`, res); + this.roleList = res.data; + }); + }, + }, + watch: { + dialogFormVisible: { + handler(newVal, oldVal) { + if (newVal == false) { + this.isUpdate = false; + this.form = {}; + this.$refs.form.resetFields(); + } else { + this.getRoleList(); + } + }, + }, + }, +}; </script> <style lang="scss" scoped> .personnel-main { - // width: 100%; // height: 100%; .page-header-search { @@ -229,7 +468,7 @@ background: #fff; padding: 20px 20px 10px 20px; - >div:nth-child(2) { + > div:nth-child(2) { display: flex; justify-content: end; margin: 10px 0; diff --git a/src/views/standardLibrary/index.vue b/src/views/standardLibrary/index.vue index 747c0e7..5c69021 100644 --- a/src/views/standardLibrary/index.vue +++ b/src/views/standardLibrary/index.vue @@ -54,13 +54,14 @@ <el-table :data="tableData" style="width: 100%; margin-bottom: 20px" - row-key="name" + row-key="id" border height="calc(100vh - 250px)" default-expand-all ref="multipleTable" @select="selectTr" @select-all="selectAll" + @selection-change="handleSelectionChange" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" > <el-table-column type="selection" label="搴忓彿"> </el-table-column> @@ -402,7 +403,6 @@ this.$message.error("娣诲姞澶辫触"); } - console.log(res); this.$message.success("娣诲姞鎴愬姛"); this.addTreeForm = { addTypeArr: [], @@ -457,20 +457,6 @@ this.isAllSelect = !this.isAllSelect; let data = this.tableData; this.toggleSelect(data, this.isAllSelect, "all"); - // 鑷畾涔� - if (this.isAllSelect) { - val.forEach((i) => { - if (i.id !== undefined) { - this.deleteList.push(i.id); - } else { - i.children.forEach((c) => { - this.deleteList.push(c.id); - }); - } - }); - } else { - this.deleteList.splice(0, this.deleteList.length); - } }, //閫夋嫨鏌愯 selectTr(selection, row) { @@ -479,33 +465,6 @@ this.isAllSelect = row.isChecked; this.toggleSelect(row, row.isChecked, "tr"); }); - - if (row.isChecked === true) { - if (row.children !== undefined) { - row.children.forEach((i) => { - this.deleteList.push(i.id); - }); - } else { - this.deleteList.push(row.id); - } - } else if (row.isChecked === false) { - if (row.children !== undefined) { - row.children.forEach((i) => { - this.deleteList.findIndex((c, index) => { - if (c === i.id) { - this.deleteList.splice(index, 1); - return; - } - }); - }); - } - this.deleteList.findIndex((c, index) => { - if (c === row.id) { - this.deleteList.splice(index, 1); - return; - } - }); - } }, //閫掑綊瀛愮骇 toggleSelect(data, flag, type) { @@ -539,6 +498,15 @@ } }); }, + handleSelectionChange(val) { + this.deleteList = [] + val.forEach((v) => { + if(v.id !== undefined){ + this.deleteList.push(v.id) + } + }) + console.log(`output->this.deleteList`,this.deleteList) + }, // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆 缁撴潫 deleteListClick() { deleteListApi(this.deleteList).then((res) => { -- Gitblit v1.9.3