Commit feb0769e authored by 11528's avatar 11528

不良定义页面

parent 29ede11a
......@@ -47,3 +47,15 @@ export function updateStatus(data) {
}
})
}
// 新增不良定义
export function addBad(data) {
data = Qs.stringify(data)
return request({
url: '/nltdisadvantage/add',
method: 'post',
data,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
}
......@@ -153,7 +153,7 @@
/>
</el-col>
</el-row>
<el-dialog :close-on-click-modal="false" class="badDialog" :title="title" :visible.sync="openBad" width="60%" append-to-body>
<el-dialog :close-on-click-modal="false" class="badDialog" title="新增不良" :visible.sync="openBad" width="60%" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
<el-row>
<el-col :span="12">
......@@ -207,14 +207,87 @@
</el-row>
<el-row>
<el-col :span="24">
<el-form-item class="labelHeight" label="具体解释" prop="specificExplanation">
<el-form-item class="labelHeight" prop="specificExplanation">
<div slot="label" class="labelClass">
<div class="labelName">具体解释</div>
<div class="labelName">Specific Explanation</div>
</div>
<el-col v-for="(item, index) in form.specificExplanation" :key="item.specificExplanation" :span="18" style="width: 70%">
<el-input v-model="item.specificExplanation" placeholder="" style="width: 70%" />
<el-link v-if="form.specificExplanation.length > 1" style="width: 20%" @click.prevent="removeDomain(item,index)">删除</el-link>
</el-col>
<el-col :span="6">
<el-link type="primary" @click="addDomain">增加一行</el-link>
</el-col>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取消</el-button>
<el-button class="redBtn" type="danger" @click="submitForm">确定</el-button>
</div>
</el-dialog>
<el-dialog :close-on-click-modal="false" class="badDialog" title="修改" :visible.sync="openBadOne" width="60%" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
<el-row>
<el-col :span="12">
<el-form-item class="labelHeight" label="不良编号" prop="rejectCode">
<div slot="label" class="labelClassRequired">
<div class="labelName">不良编号</div>
<div class="labelName">Reject Code</div>
</div>
<el-input v-model="form.rejectCode" placeholder="请输入不良编号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item class="labelHeight" label="工站" prop="Position">
<div slot="label" class="labelClass">
<div class="labelName">工站</div>
<div class="labelName">Position</div>
</div>
<el-select v-model="form.positionName" placeholder="请选择">
<el-option
v-for="dict in positionOption"
:key="dict.businessId"
:label="dict.staName"
:value="dict.businessId"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item class="labelHeight" label="不良描述" prop="phone">
<div slot="label" class="labelClass">
<div class="labelName">不良描述</div>
<div class="labelName">Reject Description</div>
</div>
<el-input v-model="form.rejectDescription" placeholder="请输入" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item class="labelHeight" label="状态" prop="email">
<div slot="label" class="labelClass">
<div class="labelName">状态</div>
<div class="labelName">Status</div>
</div>
<el-radio-group v-model="form.flag">
<el-radio label="0">停用</el-radio>
<el-radio label="1">启用</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item class="labelHeight" prop="specificExplanation">
<div slot="label" class="labelClass">
<div class="labelName">具体解释</div>
<div class="labelName">Specific Explanation</div>
</div>
<el-input v-model="form.specificExplanation" placeholder="" style="width: 70%" />
<el-link type="primary" style="width: 20%" @click="addDomain">增加一行</el-link>
<el-link @click.prevent="removeDomain(domain)">删除</el-link>
</el-form-item>
</el-col>
</el-row>
......@@ -224,12 +297,13 @@
<el-button class="redBtn" type="danger" @click="submitForm">确定</el-button>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
import { listBad, listPost, deleteLogical, updateStatus } from '@/api/badDefinition'
import { listBad, listPost, deleteLogical, updateStatus, addBad } from '@/api/badDefinition'
export default {
name: 'BadDefinition',
......@@ -250,12 +324,16 @@ export default {
position: undefined
},
openBad: false,
openBadOne: false,
form: {
explanationId: '',
rejectCode: '',
position: '',
rejectDescription: '',
flag: '',
specificExplanation: '',
specificExplanation: [
{ specificExplanation: '' }
],
positionName: ''
},
// 表单校验
......@@ -304,7 +382,10 @@ export default {
flag: undefined,
createBy: undefined,
updateBy: undefined,
remark: undefined
remark: undefined,
specificExplanation: [
{ specificExplanation: '' }
]
}
this.resetForm('form')
},
......@@ -345,7 +426,7 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
this.openBad = true
this.openBadOne = true
this.form = JSON.parse(JSON.stringify(row))
this.positionSelect()
this.title = '修改'
......@@ -354,6 +435,7 @@ export default {
/** 取消按钮操作 */
cancel() {
this.openBad = false
this.openBadOne = false
this.reset()
},
/** 新增修改页面工站下拉框 */
......@@ -381,18 +463,47 @@ export default {
row.flag = row.flag === '0' ? '1' : '0'
})
},
/** 对话框保存按钮 **/
submitForm() {
this.$refs['form'].validate(valid => {
if (valid) {
if (this.form.businessId !== undefined) {
updateStatus(this.form).then(response => {
if (response.code === 200) {
this.$message({
message: '修改成功',
type: 'success'
})
this.openBadOne = false
this.getList()
}
})
} else {
addBad(this.form).then(response => {
if (response.code === 200) {
this.$message({
message: '新增成功',
type: 'success'
})
this.open = false
this.getList()
}
})
}
}
})
},
addDomain() {
this.dynamicValidateForm.domains.push({
value: '',
key: Date.now()
this.form.specificExplanation.push({
specificExplanation: ''
})
},
/** 新增弹窗的删除按钮 */
removeDomain(item) {
var index = this.dynamicValidateForm.domains.indexOf(item)
if (index !== -1) {
this.dynamicValidateForm.domains.splice(index, 1)
removeDomain(item, index) {
if (this.form.specificExplanation.length <= 1) {
return false
}
this.form.specificExplanation.splice(index, 1)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment