'init'
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
<template>
|
||||
<el-drawer
|
||||
:append-to-body="true"
|
||||
:show-close="false"
|
||||
:visible.sync="visible"
|
||||
size="40%"
|
||||
>
|
||||
<div slot="title" style=" background-color:#02BCFF;font-size:1.5em;color:white;padding:5px 20px">
|
||||
{{ !dataForm.id ? 'btn.add' : 'btn.edit' | i18nFilter }}
|
||||
</div>
|
||||
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="100px" @keyup.enter.native="dataFormSubmit()">
|
||||
<el-form-item :label="$t('module.equipmentManager.eqManagerManage.equipmentName')" prop="equipmentId">
|
||||
<el-select v-model="dataForm.equipmentId" :placeholder="$i18nForm(['placeholder.select', $t('module.equipmentManager.eqManagerManage.equipmentName')])" clearable>
|
||||
<el-option v-for="item in eqList" :key="item.id" :value="item.id" :label="item.name" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.eqManagerManage.equipmentCode')" prop="equipmentId">
|
||||
<el-select v-model="dataForm.equipmentId" :placeholder="$i18nForm(['placeholder.select', $t('module.equipmentManager.eqManagerManage.equipmentCode')])" clearable disabled>
|
||||
<el-option v-for="item in eqList" :key="item.id" :value="item.id" :label="item.code" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.eqManagerManage.worker')" prop="workerId">
|
||||
<el-select v-model="dataForm.workerId" :placeholder="$i18nForm(['placeholder.select', $t('module.equipmentManager.eqManagerManage.worker')])" clearable @change="changeWorker">
|
||||
<el-option v-for="item in roleList" :key="item.id" :value="item.userId" :label="item.name" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="drawer-footer">
|
||||
<el-button @click="visible = false">{{ 'btn.back' | i18nFilter }}</el-button>
|
||||
<el-button type="primary" :loading="btnLoading" @click="dataFormSubmit()">{{ 'btn.confirm' | i18nFilter }}</el-button>
|
||||
</div>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getInfo, add, edit } from '@/api/equipment/eqManager'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
workerList: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
eqList: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
roleList: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
btnLoading: false,
|
||||
dataForm: {
|
||||
id: 0,
|
||||
equipmentId: '',
|
||||
workerId: ''
|
||||
},
|
||||
roleId: '',
|
||||
dataRule: {
|
||||
equipmentId: [
|
||||
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.equipmentManager.eqManagerManage.equipmentName')]), trigger: 'blur' }
|
||||
],
|
||||
workerId: [
|
||||
{ required: true, message: this.$i18nForm(['placeholder.input', this.$t('module.equipmentManager.eqManagerManage.worker')]), trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
roleObj: {}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
roleList: function(val) {
|
||||
this.roleObj = {}
|
||||
val.map(item => {
|
||||
this.roleObj[item.id] = item.dataName
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.dataForm.id = id || ''
|
||||
this.btnLoading = false
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.id) {
|
||||
getInfo({ id: this.dataForm.id }).then(res => {
|
||||
this.dataForm.equipmentId = res.data.equipmentId
|
||||
this.dataForm.workerId = res.data.workerId
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
this.btnLoading = true
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
const data = {
|
||||
'equipmentId': this.dataForm.equipmentId,
|
||||
'workerId': this.dataForm.workerId,
|
||||
'id': this.dataForm.id
|
||||
}
|
||||
if (this.dataForm.id) {
|
||||
edit(data).then(res => {
|
||||
this.$message({
|
||||
message: this.$t('module.basicData.visual.success'),
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.btnLoading = false
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
add(data).then(res => {
|
||||
this.$message({
|
||||
message: this.$t('module.basicData.visual.success'),
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
this.btnLoading = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
changeWorker(v) {
|
||||
for (let i = 0; i < this.workerList.length; i++) {
|
||||
if (v === this.workerList[i].id) {
|
||||
this.roleId = this.workerList[i].roleId
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.drawer-footer {
|
||||
width: 100%;
|
||||
margin-top: 50px;
|
||||
border-top: 1px solid #e8e8e8;
|
||||
padding: 10px 50px;
|
||||
text-align: left;
|
||||
background: #fff;
|
||||
}
|
||||
</style>
|
||||
218
src/views/EquipmentManager/equipmentManagerManage/index.vue
Normal file
218
src/views/EquipmentManager/equipmentManagerManage/index.vue
Normal file
@@ -0,0 +1,218 @@
|
||||
<!--
|
||||
/*
|
||||
* @Author: gtz
|
||||
* @Date: 2021-04-16 16:05:31
|
||||
* @LastEditTime: 2022-04-19
|
||||
* @LastEditors: juzi
|
||||
* @Description:
|
||||
*/
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<top-title />
|
||||
<head-form
|
||||
:form-config="headFormConfig"
|
||||
@headBtnClick="btnClick"
|
||||
/>
|
||||
<base-table
|
||||
:top-btn-config="topBtnConfig"
|
||||
:table-config="tableProps"
|
||||
:table-data="list"
|
||||
:is-loading="listLoading"
|
||||
:page="listQuery.current"
|
||||
:limit="listQuery.size"
|
||||
@clickTopBtn="clickTopBtn"
|
||||
>
|
||||
<method-btn slot="handleBtn" :method-list="tableBtn" @clickBtn="handleClick" />
|
||||
</base-table>
|
||||
<pagination v-show="total > listQuery.size" :total="total" :page.sync="listQuery.current" :limit.sync="listQuery.size" @pagination="getList" />
|
||||
<add-or-edit-form ref="addorEditDrawer" :role-list="roleList" :worker-list="workerList" :eq-list="eqList" :visible.sync="showAddorEditDialog" @done="getList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const topBtnConfig = [
|
||||
{
|
||||
type: 'add',
|
||||
btnName: 'btn.add'
|
||||
}
|
||||
]
|
||||
const tableBtn = [{
|
||||
type: 'edit',
|
||||
btnName: 'btn.edit'
|
||||
}, {
|
||||
type: 'delete',
|
||||
btnName: 'btn.delete'
|
||||
}]
|
||||
const tableProps = [{
|
||||
prop: 'equipmentName',
|
||||
label: i18n.t('module.equipmentManager.eqManagerManage.equipmentName'),
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'equipmentCode',
|
||||
label: i18n.t('module.equipmentManager.eqManagerManage.equipmentCode'),
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'equipmentDesc',
|
||||
label: i18n.t('module.equipmentManager.eqManagerManage.description'),
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'workerName',
|
||||
label: i18n.t('module.equipmentManager.eqManagerManage.worker'),
|
||||
align: 'center'
|
||||
}]
|
||||
// , {
|
||||
// prop: 'remark',
|
||||
// label: i18n.t('module.equipmentManager.eqManagerManage.remark'),
|
||||
// align: 'center'
|
||||
// }
|
||||
import AddOrEditForm from './AddorEditForm'
|
||||
import BaseTable from '@/components/BaseTable'
|
||||
import TopTitle from '@/components/TopTitle'
|
||||
import HeadForm from '@/components/basicData/HeadForm'
|
||||
// edit here
|
||||
import { page, del, getEqList, getWorkerList, getRoleList } from '@/api/equipment/eqManager'
|
||||
import Pagination from '@/components/Pagination'
|
||||
import MethodBtn from '@/components/BaseTable/subcomponents/MethodBtn'
|
||||
import i18n from '@/lang'
|
||||
export default {
|
||||
name: 'OrgManager',
|
||||
components: {
|
||||
TopTitle,
|
||||
HeadForm,
|
||||
Pagination,
|
||||
BaseTable,
|
||||
MethodBtn,
|
||||
AddOrEditForm
|
||||
},
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
topBtnConfig,
|
||||
tableBtn,
|
||||
tableProps,
|
||||
list: [],
|
||||
total: 0,
|
||||
listLoading: true,
|
||||
showDialog: false,
|
||||
curEditId: null,
|
||||
curStatus: null,
|
||||
showAddorEditDialog: false,
|
||||
listQuery: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
equipmentId: null,
|
||||
workerId: null
|
||||
},
|
||||
eqList: [],
|
||||
workerList: [],
|
||||
roleList: [],
|
||||
headFormConfig: [
|
||||
{
|
||||
type: 'select',
|
||||
label: this.$t('module.equipmentManager.eqManagerManage.worker'),
|
||||
selectOptions: [],
|
||||
param: 'workerId'
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
label: this.$t('module.equipmentManager.eqManagerManage.equipmentName'),
|
||||
selectOptions: [],
|
||||
param: 'equipmentId'
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: 'btn.search',
|
||||
name: 'search',
|
||||
color: 'primary'
|
||||
}
|
||||
],
|
||||
headFormValue: {}
|
||||
}
|
||||
},
|
||||
created() {},
|
||||
mounted() {
|
||||
this.getListQuery()
|
||||
},
|
||||
methods: {
|
||||
handleClick(raw) {
|
||||
switch (raw.type) {
|
||||
case 'edit':
|
||||
this.showAddorEditDialog = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addorEditDrawer.init(raw.data.id)
|
||||
})
|
||||
break
|
||||
case 'delete':
|
||||
this.$confirm(`${this.$t('module.basicData.visual.TipsBefore')}?`, this.$t('module.basicData.visual.Tips'), {
|
||||
confirmButtonText: this.$t('module.basicData.visual.confirmButtonText'),
|
||||
cancelButtonText: this.$t('module.basicData.visual.cancelButtonText'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
del({ id: raw.data.id }).then(response => {
|
||||
this.$message({
|
||||
message: this.$t('module.basicData.visual.success'),
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
})
|
||||
}).catch(() => {})
|
||||
}
|
||||
},
|
||||
handleAdd() {
|
||||
this.showAddorEditDialog = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addorEditDrawer.init()
|
||||
})
|
||||
},
|
||||
async getList() {
|
||||
this.listLoading = true
|
||||
// edit here
|
||||
this.listQuery.workerId = this.headFormValue.workerId
|
||||
this.listQuery.equipmentId = this.headFormValue.equipmentId
|
||||
const res = await page(this.listQuery)
|
||||
if (res.code === 0) {
|
||||
this.list = res.data.records
|
||||
this.total = res.data.total
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
async getListQuery() {
|
||||
const resEq = await getEqList({
|
||||
current: 1,
|
||||
size: 999
|
||||
})
|
||||
this.eqList = resEq.data.records
|
||||
this.headFormConfig[1].selectOptions = this.eqList
|
||||
const resWorker = await getWorkerList({
|
||||
current: 1,
|
||||
size: 999
|
||||
})
|
||||
this.workerList = resWorker.data.records
|
||||
const resRole = await getRoleList()
|
||||
this.roleList = resRole.data
|
||||
this.headFormConfig[0].selectOptions = this.roleList
|
||||
this.getList()
|
||||
},
|
||||
btnClick(val) {
|
||||
this.headFormValue = val
|
||||
// 如果点击的是搜索栏的其他按钮在这里继续写判断
|
||||
if (this.headFormValue.btnName === 'search') {
|
||||
this.getList()
|
||||
}
|
||||
},
|
||||
clickTopBtn(val) {
|
||||
if (val === 'add') {
|
||||
this.handleAdd()// 新增
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
Reference in New Issue
Block a user