<template>
|
<GlobalWindow
|
:title="title"
|
:visible.sync="visible"
|
:confirm-working="isWorking"
|
@confirm="confirm"
|
>
|
<el-form :model="form" ref="form" :rules="rules">
|
<el-form-item label="计价方式" prop="type">
|
<el-select v-model="form.type" placeholder="请选择计价方式" clearable>
|
<el-option
|
v-for="item in type"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="工厂" prop="departId">
|
<el-select v-model="form.departId" placeholder="请选择工厂" clearable @change="selectFactoey">
|
<el-option
|
v-for="item in factories"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="物料" prop="materialId">
|
<el-select v-model="form.materialId" placeholder="请选择物料" clearable>
|
<el-option
|
v-for="item in materials"
|
:key="item.materialId"
|
:label="item.mmodel.name"
|
:value="item.materialId"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="工序" prop="procedureId">
|
<el-select v-model="form.procedureId" placeholder="请选择计价方式" clearable>
|
<el-option
|
v-for="item in productes"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="工资单价(元)" prop="salary">
|
<el-input v-model="form.salary" placeholder="请输入工资单价(元)" v-trim/>
|
</el-form-item>
|
<el-form-item label="标准效率" prop="num">
|
<div style="display: flex;">
|
<el-input v-model="form.num" v-trim/>/
|
<el-input v-model="form.hours" v-trim/><div class="unit">小时</div>
|
<el-input v-model="form.minute" v-trim/><div class="unit">分钟</div>
|
<el-input v-model="form.second" v-trim/><div>秒</div>
|
</div>
|
</el-form-item>
|
<el-form-item label="不良品是否计入" prop="unqualified">
|
<el-switch v-model="form.unqualified" :inactive-value="0" :active-value="1"></el-switch>
|
<!-- <el-input v-model="form.unqualified" placeholder="请输入不良品是否计入 0否 1是" v-trim/> -->
|
</el-form-item>
|
|
</el-form>
|
</GlobalWindow>
|
</template>
|
|
<script>
|
import BaseOpera from '@/components/base/BaseOpera'
|
import GlobalWindow from '@/components/common/GlobalWindow'
|
import { getDepartmentListByConditon } from '@/api/ext/departmentExt'
|
import { getBomMaterialList } from '@/api/ext/bomExt'
|
import { routeExt as proceList } from '@/api/ext/routeProcedureExt'
|
export default {
|
name: 'OperaSalaryParamWindow',
|
extends: BaseOpera,
|
components: { GlobalWindow },
|
data () {
|
return {
|
// 表单数据
|
form: {
|
id: null,
|
materialId: '',
|
createUser: '',
|
createTime: '',
|
updateUser: '',
|
updateTime: '',
|
remark: '',
|
rootDepartId: '',
|
departId: '',
|
procedureId: '',
|
bomId: '',
|
salary: '',
|
num: '',
|
times: '',
|
hours: '',
|
minute: '',
|
second: '',
|
unqualified: 0,
|
type: ''
|
},
|
type: [
|
{ label: '计件', value: 0 },
|
{ label: '计时', value: 1 },
|
],
|
factories: [],
|
materials: [],
|
productes: [],
|
// 验证规则
|
rules: {
|
}
|
}
|
},
|
created () {
|
this.config({
|
api: '/business/salaryParam',
|
'field.id': 'id'
|
})
|
this.initData()
|
},
|
methods: {
|
open (title, target) {
|
this.title = title
|
this.visible = true
|
this.isEdit = false
|
// 新建
|
if (target == null) {
|
this.$nextTick(() => {
|
this.$refs.form.resetFields()
|
this.form[this.configData['field.id']] = null
|
this.form.times = ''
|
this.form.second = ''
|
this.form.minute = ''
|
this.form.hours = ''
|
this.form.departId = this.factories[0]?this.factories[0].id:''
|
this.selectFactoey(this.form.departId)
|
})
|
return
|
}
|
// 编辑
|
this.$nextTick(() => {
|
this.isEdit = true
|
for (const key in this.form) {
|
this.form[key] = target[key]
|
}
|
let { times } = target
|
this.form.second = +times%60
|
let lesMin = Math.floor(+times/60)
|
this.form.minute = lesMin%60
|
this.form.hours = Math.floor(lesMin/60)
|
this.selectFactoey(this.form.departId, true)
|
|
})
|
},
|
initData() {
|
getDepartmentListByConditon({ type: 1 })
|
.then(res => {
|
this.factories = res
|
})
|
.catch(err => {
|
console.log(err)
|
})
|
},
|
selectFactoey (v, isEdit=false) {
|
|
// console.log(v)
|
if (!isEdit) {
|
this.materials = []
|
this.form.materialId = ''
|
this.form.procedureId = ''
|
this.productes = []
|
}
|
getBomMaterialList({ departId: v })
|
.then(res => {
|
// console.log(res)
|
this.materials = res
|
if (!isEdit) {
|
this.form.materialId = res[0]?res[0].materialId:''
|
}
|
this.selectMaterial(this.form.materialId, isEdit)
|
})
|
.catch(err => {
|
console.log(err)
|
})
|
},
|
selectMaterial (id, isEdit) {
|
|
let routeId;
|
for (const item of this.materials) {
|
if (item.materialId === id) {
|
routeId = item.routeId
|
}
|
}
|
proceList(routeId)
|
.then(res => {
|
// console.log(res)
|
this.productes = res.proceList
|
if (!isEdit) {
|
this.form.procedureId = this.productes[0]?this.productes[0].id:''
|
}
|
}).catch(err => {
|
console.log(err)
|
})
|
},
|
confirm () {
|
// console.log((+this.form.hours) * 3600);
|
// console.log((+this.form.minute) * 60);
|
// console.log(this.form.second);
|
this.form.times = (+this.form.hours) * 3600 + (+this.form.minute)* 60 + (+this.form.second)
|
if (this.form.id == null || this.form.id === '') {
|
this.__confirmCreate()
|
return
|
}
|
this.__confirmEdit()
|
},
|
},
|
}
|
</script>
|
|
<style>
|
.unit {
|
white-space: nowrap;
|
}
|
</style>
|