ah_jjzhgd_webservice/ah-jjzhgd-web/src/views/basic/quality/index.vue

343 lines
11 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="app-container">
<div class="filter-container">
<el-input
v-model="listQuery.teamName"
placeholder="班组"
style="width: 200px"
class="filter-item"
:maxlength="30"
@keyup.enter.native="handleFilter"
/>
<el-input
v-model="listQuery.teamLeader"
placeholder="班组长"
style="width: 200px"
class="filter-item ml-20"
:maxlength="30"
@keyup.enter.native="handleFilter"
/>
<el-date-picker
v-model="listQuery.evalTime"
class="filter-item ml-20"
type="date"
value-format="yyyy-MM-dd"
placeholder="日期"
/>
<el-button
style="margin-left: 40px"
class="filter-item"
type="primary"
@click="handleFilter"
>
查询
</el-button>
<el-button class="filter-item" style="margin-left: 10px" type="primary" @click="handleCreate">
新增
</el-button>
</div>
<el-table
:key="tableKey"
v-loading="listLoading"
:data="list"
border
fit
highlight-current-row
style="width: 100%"
:max-height="tableHeight"
>
<el-table-column label="序号" align="center" width="80" type="index">
<template scope="scope">
<span>{{ (listQuery.pageNum - 1) * 10 + scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="班组名称" align="center" prop="teamName" />
<el-table-column label="班组长" align="center" prop="teamLeader" />
<el-table-column label="班组长手机号" align="center" prop="teamLeaderPhone" />
<el-table-column label="评价日期" align="center" prop="evalTime" />
<el-table-column label="评价人" align="center" prop="evaluator" />
<el-table-column label="评价星级" align="center" prop="score">
<template slot-scope="{ row }">
<el-rate :value="row.score" disabled :max="5" />
</template>
</el-table-column>
<el-table-column label="评价内容" align="center" prop="content" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160">
<template slot-scope="{ row, $index }">
<el-button type="primary" size="mini" @click="handleUpdate(row, $index)">编辑</el-button>
<el-button type="danger" size="mini" @click="handleDelete(row, $index)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="listQuery.pageNum"
:limit.sync="listQuery.pageSize"
@pagination="getList"
/>
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="630px" @closed="handleClosedModal">
<el-form
ref="dataForm"
:rules="rules"
:model="temp"
label-position="right"
label-width="120px"
>
<el-form-item label="班组:" prop="teamId">
<el-select v-model="temp.teamId" placeholder="班组" style="width: 100%" @change="handleChooseTeam">
<el-option v-for="item in teamList" :key="item.id" :value="item.id" :label="item.name" />
</el-select>
</el-form-item>
<el-form-item label="班组长:" prop="teamLeader">
<el-input v-model="temp.teamLeader" placeholder="班组长" :maxlength="50" disabled />
</el-form-item>
<el-form-item label="班组长手机号:" prop="teamLeaderPhone">
<el-input v-model="temp.teamLeaderPhone" placeholder="班组长手机号" :maxlength="50" disabled />
</el-form-item>
<el-form-item label="评价星级:" prop="score" :max="5">
<!-- <el-input v-model="temp.score" placeholder="评价星级" :maxlength="50" />-->
<el-rate v-model="temp.score" />
</el-form-item>
<el-form-item label="评级内容:" prop="content">
<el-input v-model="temp.content" placeholder="评级内容" :maxlength="50" type="textarea" :rows="2" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false"> 关闭 </el-button>
<el-button v-throttle-click="dialogStatus === 'create' ? createData : updateData" type="primary">
提交
</el-button>
</div>
</el-dialog>
<modul-dialog ref="pwdVerifiersDialog" :title="componentDialog.title" :width="componentDialog.width"
v-model="componentDialog.openFalg">
<component :is="componentDialog.modulName" />
</modul-dialog>
</div>
</template>
<script>
import Pagination from '@/components/Pagination'
import _ from 'lodash/fp'
import {
addQualityItem,
deleteQualityItem,
getQualityItemDetail,
getQualityList, getQualityTeamList,
updateQualityItem
} from '@/api/basic/quality'
import { verifyPwd } from '@/api/verifyPwd'
import modulDialog from '@/components/pwdVerifiers/pwdVerifiers.vue'
import {decryptData} from '@/utils/test';
import {desensitize} from '@/utils/hyposensitization.js';
const defaultTmp = {
teamId: '',
teamName: '',
teamLeader: '',
teamLeaderPhone: '',
evalTime: '',
evaluator: '',
score: 0,
content: ''
}
export default {
components: { Pagination,modulDialog },
data() {
return {
componentDialog: {
modulName: '', //组件名称
title: '',
width: '',
openFalg: false
},
tableKey: 0,
list: [],
teamList: [],
total: 0,
listLoading: false,
listQuery: {
pageNum: 1,
pageSize: 10,
teamName: '',
teamLeader: '',
evalTime: ''
},
tableHeight: 650,
showReviewer: false,
temp: _.cloneDeep(defaultTmp),
dialogFormVisible: false,
dialogStatus: '',
downloadLoading: false,
textMap: {
update: '编辑',
create: '新增'
},
dialogPvVisible: false,
rules: {
teamId: [{ required: true, message: '不能为空', trigger: 'change' }],
teamName: [{ required: true, message: '不能为空', trigger: 'blur' }],
teamLeader: [{ required: true, message: '不能为空', trigger: 'blur' }],
teamLeaderPhone: [{ required: true, message: '不能为空', trigger: 'blur' }],
score: [{ required: true, message: '不能为空', trigger: 'change' }],
content: [{ required: true, message: '不能为空', trigger: 'blur' }]
}
}
},
created() {
this.getList()
this.getTeamList()
},
methods: {
openModulDialog(title, modulName, width, openFalg) {
this.componentDialog.title = title
this.componentDialog.modulName = modulName
this.componentDialog.width = width
this.componentDialog.openFalg = openFalg
},
verifiersPwd(data) {
verifyPwd(data).then((response) => {
this.$message({
showClose: true,
message: response.msg,
type: 'success',
duration: 500
})
// 关闭验证密码页面
this.componentDialog.openFalg = false;
if (this.$refs.pwdVerifiersDialog) {
this.$refs.pwdVerifiersDialog.resetForm();
}
this.commitUpdateData();
})
},
// 获取班组列表
getTeamList() {
getQualityTeamList().then(res => {
this.teamList = res.data
})
},
handleChooseTeam(val) {
const currentTeam = this.teamList.find(item => item.id === val)
this.temp.teamName = currentTeam.name
this.temp.teamLeader = currentTeam.teamLeader
this.temp.teamLeaderPhone = currentTeam.teamLeaderPhone
},
getList() {
this.listLoading = true
getQualityList(this.listQuery).then((response) => {
this.list = response.rows.map(item => {
const { score } = item
item.score = Number(score)
if (item.score > 5) item.score = 5
return item
})
this.total = response.total
}).finally(() => {
})
setTimeout(()=>{
this.listLoading = false
},500)
},
// 查询
handleFilter() {
this.listQuery.pageNum = 1
this.getList()
},
// 新增
handleCreate() {
this.dialogStatus = 'create'
this.dialogFormVisible = true
},
createData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
addQualityItem(this.temp).then((response) => {
this.$message({
showClose: true,
message: response.msg,
type: 'success',
duration: 2000
})
this.getList()
this.dialogFormVisible = false
}).finally(() => {
})
}
})
},
// 编辑
handleUpdate(row) {
getQualityItemDetail({ evalId: row.evalId }).then((res) => {
const { score } = res.data
this.temp = Object.assign({}, res.data)
this.temp.score = Number(score)
if (this.temp.score > 5) this.temp.score = 5
this.temp.teamId = row.teamId
if(row.teamLeaderPhone){
let teamLeaderPhone = decryptData(row.teamLeaderPhone).replace(/\/g, '');
this.temp.teamLeaderPhone = desensitize(teamLeaderPhone,'phone');
}
})
this.dialogStatus = 'update'
this.dialogFormVisible = true
},
updateData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.openModulDialog('验证密码', 'pwdVerifiers', '600px', true)
}
})
},
commitUpdateData() {
updateQualityItem(this.temp).then((response) => {
this.$message({
showClose: true,
message: response.msg,
type: 'success',
duration: 2000
})
this.getList()
this.dialogFormVisible = false
}).finally(() => {
})
},
// 删除数据
handleDelete(row, index) {
this.$confirm(`确定要删除该数据吗?`, {
type: 'warning',
title: '操作提示',
beforeClose: async(action, instance, done) => {
if (action === 'confirm') {
deleteQualityItem({ evalId: row.evalId }).then((response) => {
done()
this.$message({
showClose: true,
message: response.msg,
type: 'success',
duration: 2000
})
this.getList()
})
} else {
done()
}
}
})
},
handleClosedModal() {
this.$refs['dataForm'].resetFields()
this.temp = _.cloneDeep(defaultTmp)
}
}
}
</script>