From b4c40a33424867db31b88bd4fb7d6d72a6b537be Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期三, 19 二月 2025 10:15:45 +0800 Subject: [PATCH] 岗位职责导出bug --- src/components/do/a6-personnel/job-responsibilities.vue | 484 ++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 331 insertions(+), 153 deletions(-) diff --git a/src/components/do/a6-personnel/job-responsibilities.vue b/src/components/do/a6-personnel/job-responsibilities.vue index f3ddb6f..4826e4a 100644 --- a/src/components/do/a6-personnel/job-responsibilities.vue +++ b/src/components/do/a6-personnel/job-responsibilities.vue @@ -3,8 +3,16 @@ <div class="view"> <div style="text-align: left; margin-bottom: 15px;padding: 0 10px"> <label>鍛樺伐锛�</label> - <el-input v-model="userName" clearable placeholder="璇疯緭鍏ュ憳宸�" size="small" style="width: 20vh;"></el-input> - <el-button size="small" type="primary" @click="refreshTable">鏌ヨ</el-button> + <el-input + v-model="userName" + clearable + placeholder="璇疯緭鍏ュ憳宸�" + size="small" + style="width: 20vh;" + ></el-input> + <el-button size="small" type="primary" @click="refreshTable" + >鏌ヨ</el-button + > <div v-if="isDepartment" style="float: right;"> <el-button size="small" type="primary" @click="addPost">鏂板</el-button> <!-- <el-button size="small" type="primary">瀵煎嚭excel</el-button>--> @@ -13,41 +21,108 @@ <div class="table" style="padding: 0 10px"> <el-table :data="tableData" height="70vh" style="width: 100%"> <el-table-column label="搴忓彿" type="index" width="60"></el-table-column> - <el-table-column label="鍛樺伐缂栧彿" min-width="120" prop="account"></el-table-column> - <el-table-column label="宀椾綅鍚嶇О" min-width="180" prop="postName"></el-table-column> - <el-table-column label="鎵�灞為儴闂�" min-width="180" prop="departLimsName"></el-table-column> - <el-table-column label="宸ヤ綔鐩爣" min-width="180" prop="jobObjective"></el-table-column> - <el-table-column label="宀椾綅鑱岃矗" min-width="180" prop="jobResponsibilities"></el-table-column> - <el-table-column label="浠昏亴浜�" min-width="180" prop="incumbentName"></el-table-column> - <el-table-column label="浠昏亴浜哄鏍告棩鏈�" min-width="180" prop="incumbentDate"></el-table-column> - <el-table-column label="涓荤" min-width="180" prop="supervisorName"></el-table-column> - <el-table-column label="涓荤瀹℃牳鏃ユ湡" min-width="180" prop="supervisorDate"></el-table-column> + <el-table-column + label="鍛樺伐缂栧彿" + min-width="120" + prop="account" + ></el-table-column> + <el-table-column + label="宀椾綅鍚嶇О" + min-width="180" + prop="postName" + ></el-table-column> + <el-table-column + label="鎵�灞為儴闂�" + min-width="180" + prop="departLimsName" + ></el-table-column> + <el-table-column + label="宸ヤ綔鐩爣" + min-width="180" + prop="jobObjective" + ></el-table-column> + <el-table-column + label="宀椾綅鑱岃矗" + min-width="180" + prop="jobResponsibilities" + ></el-table-column> + <el-table-column + label="浠昏亴浜�" + min-width="180" + prop="incumbentName" + ></el-table-column> + <el-table-column + label="浠昏亴浜哄鏍告棩鏈�" + min-width="180" + prop="incumbentDate" + ></el-table-column> + <el-table-column + label="涓荤" + min-width="180" + prop="supervisorName" + ></el-table-column> + <el-table-column + label="涓荤瀹℃牳鏃ユ湡" + min-width="180" + prop="supervisorDate" + ></el-table-column> <el-table-column fixed="right" label="鎿嶄綔" width="140"> <template v-slot="scope"> - <el-button v-if="!isDepartment || scope.row.currentState === '鍏抽棴'" size="small" type="text" - @click="handleViewClick(scope.row, 'view')">鏌ョ湅 + <el-button + v-if="!isDepartment || scope.row.currentState === '鍏抽棴'" + size="small" + type="text" + @click="handleViewClick(scope.row, 'view')" + >鏌ョ湅 </el-button> - <el-button v-if="isDepartment && scope.row.currentState !== '鍏抽棴'" size="small" type="text" - @click="handleViewClick(scope.row, 'edit')">缂栬緫 + <el-button + v-if="isDepartment && scope.row.currentState !== '鍏抽棴'" + size="small" + type="text" + @click="handleViewClick(scope.row, 'edit')" + >缂栬緫 </el-button> - <el-button size="small" type="text" @click="downLoadPost(scope.row)">涓嬭浇</el-button> - <el-button v-if="isDepartment" size="small" type="text" @click="deletePost(scope.row)">鍒犻櫎</el-button> + <el-button size="small" type="text" @click="downLoadPost(scope.row)" + >涓嬭浇</el-button + > + <el-button + v-if="isDepartment" + size="small" + type="text" + @click="deletePost(scope.row)" + >鍒犻櫎</el-button + > </template> </el-table-column> </el-table> - <el-pagination :current-page="1" :page-size="search.size" :page-sizes="[10, 20, 30, 50, 100]" - :total="search.total" layout="->,total, sizes, prev, pager, next, jumper" - @size-change="handleSizeChange" - @current-change="handleCurrentChange"> + <el-pagination + :current-page="1" + :page-size="search.size" + :page-sizes="[10, 20, 30, 50, 100]" + :total="search.total" + layout="->,total, sizes, prev, pager, next, jumper" + @size-change="handleSizeChange" + @current-change="handleCurrentChange" + > </el-pagination> </div> <!-- 鏂板宀椾綅鑱岃矗 --> - <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible" - title="鏂板宀椾綅鑱岃矗" - width="50%" @close="resetForm"> + <el-dialog + :close-on-click-modal="false" + :close-on-press-escape="false" + :visible.sync="dialogVisible" + title="鏂板宀椾綅鑱岃矗" + width="50%" + @close="resetForm" + > <el-steps :active="currentStep" align-center finish-status="success"> - <el-step v-for="(v, i) in steps" :key="i" :title="v" style="cursor:pointer" - @click.native="choiceStep(i)"></el-step> + <el-step + v-for="(v, i) in steps" + :key="i" + :title="v" + style="cursor:pointer" + @click.native="choiceStep(i)" + ></el-step> </el-steps> <el-form ref="form" :model="form" :rules="rules" label-width="130px"> <div> @@ -56,46 +131,97 @@ <el-row> <el-col :span="12"> <el-form-item label="宀椾綅鍚嶇О锛�" prop="postName"> - <el-input v-model="form.postName" :disabled="currentStep !== 0 || operationType === 'view'" - size="small"></el-input> + <el-input + v-model="form.postName" + :disabled="currentStep !== 0 || operationType === 'view'" + size="small" + ></el-input> </el-form-item> </el-col> <el-col :span="24"> <el-form-item label="宸ヤ綔鐩爣锛�" prop="jobObjective"> - <el-input v-model="form.jobObjective" :disabled="currentStep !== 0 || operationType === 'view'" - size="small" - type="textarea"></el-input> + <el-input + v-model="form.jobObjective" + :disabled="currentStep !== 0 || operationType === 'view'" + size="small" + type="textarea" + ></el-input> </el-form-item> </el-col> <el-col :span="24"> <el-form-item label="宀椾綅鑱岃矗锛�" prop="jobResponsibilities"> - <el-input v-model="form.jobResponsibilities" :disabled="currentStep !== 0 || operationType === 'view'" - size="small" - type="textarea"></el-input> + <el-input + v-model="form.jobResponsibilities" + :disabled="currentStep !== 0 || operationType === 'view'" + size="small" + type="textarea" + ></el-input> </el-form-item> </el-col> - <el-col v-if="currentStep === 0 || operationType === 'view'" :span="12"> + <el-col + v-if="currentStep === 0 || operationType === 'view'" + :span="12" + > <el-form-item - :rules="[{ required: currentStep === 0, message: '璇烽�夋嫨浠昏亴浜�', trigger: 'change' }]" + :rules="[ + { + required: currentStep === 0, + message: '璇烽�夋嫨浠昏亴浜�', + trigger: 'change' + } + ]" label="浠昏亴浜猴細" - prop="incumbentId"> - <el-select v-model="form.incumbentId" :disabled="operationType === 'view'" clearable - filterable - placeholder="璇烽�夋嫨浠昏亴浜�" size="small" style="width: 100%;"> - <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id"> + prop="incumbentId" + > + <el-select + v-model="form.incumbentId" + :disabled="operationType === 'view'" + clearable + filterable + placeholder="璇烽�夋嫨浠昏亴浜�" + size="small" + style="width: 100%;" + > + <el-option + v-for="item in responsibleOptions" + :key="item.id" + :label="item.name" + :value="item.id" + > </el-option> </el-select> </el-form-item> </el-col> - <el-col v-if="currentStep === 1 || operationType === 'view'" :span="12"> + <el-col + v-if="currentStep === 1 || operationType === 'view'" + :span="12" + > <el-form-item - :rules="[{ required: currentStep === 1, message: '璇烽�夋嫨涓荤', trigger: 'blur' }]" + :rules="[ + { + required: currentStep === 1, + message: '璇烽�夋嫨涓荤', + trigger: 'blur' + } + ]" label="涓荤锛�" - prop="supervisorId"> - <el-select v-model="form.supervisorId" :disabled="currentStep !== 1 || operationType === 'view'" - clearable filterable - placeholder="璇烽�夋嫨涓荤" size="small" style="width: 100%;"> - <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id"> + prop="supervisorId" + > + <el-select + v-model="form.supervisorId" + :disabled="currentStep !== 1 || operationType === 'view'" + clearable + filterable + placeholder="璇烽�夋嫨涓荤" + size="small" + style="width: 100%;" + > + <el-option + v-for="item in responsibleOptions" + :key="item.id" + :label="item.name" + :value="item.id" + > </el-option> </el-select> </el-form-item> @@ -103,33 +229,39 @@ </el-row> </el-card> <el-row style="margin-top: 1em;"> - <el-col :span="4"> - 鎿嶄綔浜猴細{{ form.submitPerson }} - </el-col> - <el-col :span="6"> - 鏃ユ湡锛歿{ form.submitDate }} - </el-col> + <el-col :span="4"> 鎿嶄綔浜猴細{{ form.submitPerson }} </el-col> + <el-col :span="6"> 鏃ユ湡锛歿{ form.submitDate }} </el-col> </el-row> </div> </el-form> <span slot="footer" class="dialog-footer"> - <el-button v-if="currentStep !== 0 && currentStep !== 3" @click="submitForm('3reject')">椹冲洖</el-button> - <el-button v-if="currentStep === 0" @click="submitForm('2save')">淇濆瓨</el-button> - <el-button v-if="currentStep !== 3" type="primary" - @click="submitForm('1submit')">{{ currentStep === 0 ? '鎻愪氦' : '閫氳繃' }}</el-button> + <el-button + v-if="currentStep !== 0 && currentStep !== 3" + @click="submitForm('3reject')" + >椹冲洖</el-button + > + <el-button v-if="currentStep === 0" @click="submitForm('2save')" + >淇濆瓨</el-button + > + <el-button + v-if="currentStep !== 3" + type="primary" + @click="submitForm('1submit')" + >{{ currentStep === 0 ? "鎻愪氦" : "閫氳繃" }}</el-button + > </span> </el-dialog> </div> </template> <script> -import { dateFormat } from '../../../util/date'; -import { deletePersonCommunicationAbility } from '../../../assets/api/api'; +import { dateFormat } from "../../../util/date"; +import { deletePersonCommunicationAbility } from "../../../assets/api/api"; export default { data() { return { - userName: '', + userName: "", tableData: [], responsibleOptions: [], search: { @@ -140,21 +272,31 @@ dialogVisible: false, currentStep: 0, // 姝ラ鏉℃樉绀虹鍑犳 currentStepClick: 0, // 鐐瑰嚮姝ラ鏉″彉鍖� - operationType: '', - steps: ['鎻愪氦', '浠昏亴浜虹‘璁�', '涓荤纭'], + operationType: "", + steps: ["鎻愪氦", "浠昏亴浜虹‘璁�", "涓荤纭"], form: { - postName: '', // 宀椾綅鍚嶇О - jobObjective: '', // 宸ヤ綔鐩爣 - jobResponsibilities: '', // 宀椾綅鑱岃矗 - incumbentId: '', // 浠昏亴浜� - supervisorId: '' // 涓荤 + postName: "", // 宀椾綅鍚嶇О + jobObjective: "", // 宸ヤ綔鐩爣 + jobResponsibilities: "", // 宀椾綅鑱岃矗 + incumbentId: "", // 浠昏亴浜� + supervisorId: "" // 涓荤 }, rules: { - postName: [{ required: true, message: '璇疯緭鍏ュ矖浣嶅悕绉�', trigger: 'blur' }], - jobObjective: [{ required: true, message: '璇疯緭鍏ュ伐浣滅洰鏍�', trigger: 'blur' }], - jobResponsibilities: [{ required: true, message: '璇疯緭鍏ュ矖浣嶈亴璐�', trigger: 'blur' }], - incumbentId: [{ required: true, message: '璇烽�夋嫨浠昏亴浜�', trigger: 'change' }], - supervisorId: [{ required: true, message: '璇烽�夋嫨涓荤', trigger: 'change' }] + postName: [ + { required: true, message: "璇疯緭鍏ュ矖浣嶅悕绉�", trigger: "blur" } + ], + jobObjective: [ + { required: true, message: "璇疯緭鍏ュ伐浣滅洰鏍�", trigger: "blur" } + ], + jobResponsibilities: [ + { required: true, message: "璇疯緭鍏ュ矖浣嶈亴璐�", trigger: "blur" } + ], + incumbentId: [ + { required: true, message: "璇烽�夋嫨浠昏亴浜�", trigger: "change" } + ], + supervisorId: [ + { required: true, message: "璇烽�夋嫨涓荤", trigger: "change" } + ] } // departId: 0 }; @@ -178,13 +320,13 @@ addPost() { this.dialogVisible = true; this.form = { - postName: '', // 宀椾綅鍚嶇О - jobObjective: '', // 宸ヤ綔鐩爣 - jobResponsibilities: '', // 宀椾綅鑱岃矗 - incumbentId: '', // 浠昏亴浜� - supervisorId: '', // 鎿嶄綔浜� - submitPerson: '', // 涓荤 - submitDate: '', // 鏃ユ湡 + postName: "", // 宀椾綅鍚嶇О + jobObjective: "", // 宸ヤ綔鐩爣 + jobResponsibilities: "", // 宀椾綅鑱岃矗 + incumbentId: "", // 浠昏亴浜� + supervisorId: "", // 鎿嶄綔浜� + submitPerson: "", // 涓荤 + submitDate: "", // 鏃ユ湡 currentStep: 0 // 鏃ユ湡 }; this.currentStep = 0; @@ -193,19 +335,31 @@ // 鏌ヨ鍒楄〃淇℃伅 getPostList(userId) { this.search.userId = userId; - const name = this.isDepartment ? 'departmentId' : 'userId'; - this.$axios.get(this.$api.personnel.personJobResponsibilitiesSelect + '?userName=' + this.userName + `&${name}=` + this.search.userId + '&size=' + this.search.size + '¤t=' + this.search.current).then(res => { - if (res.code === 201) return; - this.tableData = res.data.records; - this.search.total = res.data.total; - }); + const name = this.isDepartment ? "departmentId" : "userId"; + this.$axios + .get( + this.$api.personnel.personJobResponsibilitiesSelect + + "?userName=" + + this.userName + + `&${name}=` + + this.search.userId + + "&size=" + + this.search.size + + "¤t=" + + this.search.current + ) + .then(res => { + if (res.code === 201) return; + this.tableData = res.data.records; + this.search.total = res.data.total; + }); }, //鎻愪氦琛ㄥ崟 async submitForm(saveState) { - this.$refs.form.validate((valid) => { - if (valid === true || saveState !== '1submit') { + this.$refs.form.validate(valid => { + if (valid === true || saveState !== "1submit") { // 缁欏綋鍓嶇幆鑺傝缃垱寤轰汉涓庢椂闂� - let user = JSON.parse(localStorage.getItem('user')); + let user = JSON.parse(localStorage.getItem("user")); const dateTime = dateFormat(new Date()); // 鑾峰彇褰撳墠鐜妭鎿嶄綔浜轰笌鏃ユ湡 switch (this.currentStep) { @@ -225,7 +379,9 @@ break; } // 鑾峰彇褰撳墠鐜妭璐熻矗浜� - switch (saveState === '3reject' ? this.currentStep - 1 : this.currentStep) { + switch ( + saveState === "3reject" ? this.currentStep - 1 : this.currentStep + ) { case 1: this.form.currentResponsible = this.form.submittingOperator; break; @@ -239,37 +395,44 @@ // 璁剧疆璇ユ搷浣滃垽鏂槸鍚︿负鎻愪氦锛屼繚瀛橈紝椹冲洖锛岄�氳繃 switch (saveState) { // 鎻愪氦锛岄�氳繃 - case '1submit': + case "1submit": currentStepAction = this.currentStep + 1; break; // 淇濆瓨 - case '2save': + case "2save": currentStepAction = this.currentStep; break; // 椹冲洖 - case '3reject': + case "3reject": currentStepAction = this.currentStep - 1; break; default: break; } // 鑾峰彇褰撳墠鐘舵�� - this.form.currentState = currentStepAction === 3 ? '鍏抽棴' : this.steps[currentStepAction]; - this.$axios.post(this.$api.personnel.personJobResponsibilitiesSave, this.form, { - headers: { - 'Content-Type': 'application/json' - }, - noQs: true - }).then(res => { - if (res.code == 200) { - this.$message.success('鎻愪氦鎴愬姛'); - this.getPostList(this.departId); - this.dialogVisible = false; - } - }); + this.form.currentState = + currentStepAction === 3 ? "鍏抽棴" : this.steps[currentStepAction]; + this.$axios + .post( + this.$api.personnel.personJobResponsibilitiesSave, + this.form, + { + headers: { + "Content-Type": "application/json" + }, + noQs: true + } + ) + .then(res => { + if (res.code == 200) { + this.$message.success("鎻愪氦鎴愬姛"); + this.getPostList(this.departId); + this.dialogVisible = false; + } + }); } else { let step = this.steps[this.currentStep]; - this.$message.warning(step + ' 娴佺▼涓湁蹇呭~椤规湭濉紒'); + this.$message.warning(step + " 娴佺▼涓湁蹇呭~椤规湭濉紒"); } }); }, @@ -280,20 +443,20 @@ row.incumbentId = Number(row.incumbentId); this.form = { ...row }; switch (row.currentState) { - case '鎻愪氦': + case "鎻愪氦": this.currentStep = 0; break; - case '浠昏亴浜虹‘璁�': + case "浠昏亴浜虹‘璁�": this.currentStep = 1; this.form.submitPerson = row.submittingOperator; this.form.submitDate = row.submittingDate; break; - case '涓荤纭': + case "涓荤纭": this.currentStep = 2; this.form.submitPerson = row.incumbentOperator; this.form.submitDate = row.incumbentDate; break; - case '鍏抽棴': + case "鍏抽棴": this.currentStep = 3; this.form.submitPerson = row.supervisorOperator; this.form.submitDate = row.supervisorDate; @@ -302,58 +465,74 @@ break; } this.form.currentState = this.currentStep; - this.currentStepClick = this.currentStep === 3 ? 0 : this.currentStep - console.log('this.form---', this.form); + this.currentStepClick = this.currentStep === 3 ? 0 : this.currentStep; + console.log("this.form---", this.form); this.dialogVisible = true; }, // 涓嬭浇宀椾綅鑱岃矗 downLoadPost(row) { - this.$axios.post(this.$api.personPostAuthorizationRecord.exportPersonJobResponsibilities,{id:row.id},{responseType: "blob"}).then(res => { - this.$message.success('涓嬭浇鎴愬姛') - //灏咮lob 瀵硅薄杞崲鎴愬瓧绗︿覆 - let reader = new FileReader(); - reader.readAsText(blob, 'utf-8'); - reader.onload = () => { - try { - let result = JSON.parse(reader.result); - if (result.message) { - this.$message.error(result.message); - } else { + this.$axios + .post( + this.$api.personPostAuthorizationRecord + .exportPersonJobResponsibilities, + { id: row.id }, + { responseType: "blob" } + ) + .then(res => { + this.$message.success("涓嬭浇鎴愬姛"); + //灏咮lob 瀵硅薄杞崲鎴愬瓧绗︿覆 + const blob = new Blob([res], { type: "application/msword" }); + let reader = new FileReader(); + reader.readAsText(blob, "utf-8"); + reader.onload = () => { + try { + let result = JSON.parse(reader.result); + if (result.message) { + this.$message.error(result.message); + } else { + const url = URL.createObjectURL(blob); + const link = document.createElement("a"); + link.href = url; + link.download = row.incumbentName + "-宀椾綅鑱岃矗" + ".docx"; + link.click(); + this.$message.success("瀵煎嚭鎴愬姛"); + } + } catch (err) { + console.log(err); const url = URL.createObjectURL(blob); - const link = document.createElement('a'); + const link = document.createElement("a"); link.href = url; - link.download = row.incumbentName+'-宀椾綅鑱岃矗'+'.docx'; + link.download = row.incumbentName + "-宀椾綅鑱岃矗" + ".docx"; link.click(); - this.$message.success('瀵煎嚭鎴愬姛') + this.$message.success("瀵煎嚭鎴愬姛"); } - } catch (err) { - console.log(err); - const url = URL.createObjectURL(blob); - const link = document.createElement('a'); - link.href = url; - link.download = row.incumbentName+'-宀椾綅鑱岃矗'+'.docx'; - link.click(); - this.$message.success('瀵煎嚭鎴愬姛') - } - } - }) + }; + }); }, // 鍒犻櫎宀椾綅鑱岃矗 deletePost(row) { - this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎姝ゆ暟鎹�, 鏄惁缁х画?', '鎻愮ず', { - confirmButtonText: '纭畾', - cancelButtonText: '鍙栨秷', - type: 'warning' - }).then(() => { - this.$axios.delete(this.$api.personnel.personJobResponsibilitiesDelete + '?id=' + row.id).then(res => { - if (res.code == 200) { - this.$message.success('鍒犻櫎鎴愬姛'); - this.getPostList(this.departId); - } + this.$confirm("姝ゆ搷浣滃皢姘镐箙鍒犻櫎姝ゆ暟鎹�, 鏄惁缁х画?", "鎻愮ず", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning" + }) + .then(() => { + this.$axios + .delete( + this.$api.personnel.personJobResponsibilitiesDelete + + "?id=" + + row.id + ) + .then(res => { + if (res.code == 200) { + this.$message.success("鍒犻櫎鎴愬姛"); + this.getPostList(this.departId); + } + }); + }) + .catch(() => { + this.$message.error("鍒犻櫎澶辫触"); }); - }).catch(() => { - this.$message.error('鍒犻櫎澶辫触'); - }); }, resetForm() { this.$refs.form.resetFields(); @@ -390,5 +569,4 @@ } }; </script> -<style scoped> -</style> +<style scoped></style> -- Gitblit v1.9.3