<template>
|
<a-modal
|
:title="title"
|
:visible="visible"
|
:fullScreen="true"
|
:width="1200"
|
@ok="handleOk"
|
@cancel="handleCancel"
|
:maskClosable="false"
|
>
|
<a-spin :spinning="confirmLoading">
|
<a-form :form="form">
|
<a-row style="width: 100%">
|
<a-col :span="24 / 2">
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="检验方案编码">
|
<a-input :disabled="disableSubmit" placeholder="请输入检验方案编码" v-decorator="['planCode', validatorRules.planCode]" />
|
</a-form-item>
|
</a-col>
|
<a-col :span="24 / 2">
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="检验方案名称">
|
<a-input :disabled="disableSubmit" placeholder="请输入检验方案名称" v-decorator="['planName', validatorRules.planName]" />
|
</a-form-item>
|
</a-col>
|
</a-row>
|
<a-row style="width: 100%">
|
<a-col :span="24 / 2">
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="检验方案分类">
|
<j-dict-select-tag
|
:disabled="disableSubmit"
|
type="list"
|
v-decorator="['planCategory', validatorRules.planCategory]"
|
:triggerChange="true"
|
dictCode="plan_category"
|
placeholder="请选择检验方案分类"
|
/>
|
</a-form-item>
|
</a-col>
|
<a-col :span="24 / 2">
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="抽样规则">
|
<a-select
|
:disabled="disableSubmit"
|
:triggerChange="true"
|
:options="ruleOptions"
|
v-decorator="[ 'ruleId', validatorRules.ruleId ]"
|
placeholder='请选择抽样规则'
|
/>
|
</a-form-item>
|
</a-col>
|
</a-row>
|
<a-row style="width: 100%">
|
<a-col :span="24 / 2">
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="物料编码">
|
<a-input-search v-decorator="['materialNumber', validatorRules.materialNumber]" :disabled="disableSubmit" @search="materialSearch" enter-button
|
placeholder='请选择物料信息'/>
|
</a-form-item>
|
</a-col>
|
<a-col :span="24 / 2">
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="物料名称">
|
<a-input :disabled="true" v-decorator="['materialName', validatorRules.materialName]" placeholder='选择物料后自动带出' />
|
</a-form-item>
|
</a-col>
|
</a-row>
|
<a-row style="width: 100%">
|
<a-col :span="24">
|
<a-form-item :labelCol="{ span: 3 }" :wrapperCol="{ span: 21 }" label="方案描述">
|
<a-textarea
|
:disabled="disableSubmit"
|
:rows="2"
|
placeholder="..."
|
v-decorator="['descreption', validatorRules.descreption]"
|
/>
|
</a-form-item>
|
</a-col>
|
</a-row>
|
</a-form>
|
</a-spin>
|
<a-button type="primary" :style="{ marginBottom: '8px' }" @click="selectInspectionItemList()" :disabled="disableSubmit">选择检验项目</a-button>
|
<a-table
|
ref="table"
|
bordered
|
size="middle"
|
rowKey="id"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
:loading="loading"
|
@change="handleTableChange"
|
>
|
<template v-for="col in columns" :slot="col.dataIndex" slot-scope="text, record, index">
|
<div :key="col.dataIndex">
|
<a-input-number
|
:disabled="disableSubmit"
|
v-if="col.dataIndex == 'sorter'"
|
:value="text"
|
@change="(e) => handleChange(e, record.key, col, index)"
|
:min="1"
|
/>
|
</div>
|
<div :key="col.dataIndex">
|
<a-input-number
|
:disabled="disableSubmit"
|
v-if="col.dataIndex == 'standardValue'"
|
:value="text"
|
@change="(e) => handleChange(e, record.key, col, index)"
|
:min="0"
|
/>
|
</div>
|
<div :key="col.dataIndex">
|
<a-input-number
|
:disabled="disableSubmit"
|
v-if="col.dataIndex == 'maxValue'"
|
:value="text"
|
@change="(e) => handleChange(e, record.key, col, index)"
|
:min="0"
|
/>
|
</div>
|
<div :key="col.dataIndex">
|
<a-input-number
|
:disabled="disableSubmit"
|
v-if="col.dataIndex == 'minValue'"
|
:value="text"
|
@change="(e) => handleChange(e, record.key, col, index)"
|
:min="0"
|
/>
|
</div>
|
</template>
|
<span slot="action" slot-scope="text, record, index">
|
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record, index)" :disabled="disableSubmit">
|
<a>删除</a>
|
</a-popconfirm>
|
</span>
|
</a-table>
|
<template slot="footer" v-if="disableSubmit == false">
|
<a-button :style="{ marginRight: '8px' }" @click="handleCancel">关闭</a-button>
|
<a-button @click="handleOk" :disabled="isDisabled" type="primary">确定</a-button>
|
</template>
|
|
<template slot="footer" v-if="disableSubmit == true">
|
<a-button :style="{ marginRight: '8px' }" @click="handleCancel">关闭</a-button>
|
</template>
|
<j-select-inspection-item-list-modal ref="inspectionItemForm" @ok="modalFormOk"></j-select-inspection-item-list-modal>
|
<material-list-modal ref="materialListModel" @sendSelectionRows="getMaterialRows"></material-list-modal>
|
</a-modal>
|
</template>
|
|
<script>
|
import pick from 'lodash.pick'
|
import { ajaxGetDictItems } from '@/api/api'
|
import moment from 'moment'
|
import { getAction, postAction, requestPut } from '@/api/manage'
|
import JDictSelectTag from '@/components/dict/JDictSelectTag'
|
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
|
import JMultiSelectTag from '@/components/dict/JMultiSelectTag'
|
import { filterObj } from '@/utils/util'
|
import JSelectInspectionItemListModal from './JSelectInspectionItemListModal'
|
import store from '@/store'
|
import MaterialListModal from './MaterialListModal'
|
|
export default {
|
name: 'InspectionPlanModel',
|
components: {
|
JMultiSelectTag,
|
JDictSelectTag,
|
JSelectInspectionItemListModal,
|
JSearchSelectTag,
|
store,
|
MaterialListModal
|
},
|
data() {
|
return {
|
/* 分页参数 */
|
ipagination: {
|
current: 1,
|
pageSize: 10,
|
pageSizeOptions: ['10', '20', '30'],
|
showTotal: (total, range) => {
|
return range[0] + '-' + range[1] + ' 共' + total + '条'
|
},
|
showQuickJumper: true,
|
showSizeChanger: true,
|
total: 0
|
},
|
isDisabled: false,
|
selectedRowKeys: {},
|
state: {
|
show: false,
|
maintenanceValue: 1,
|
checkValue: 1,
|
maintenanceState: false,
|
checkState: false,
|
},
|
inboundDate: '',
|
applicationDate: '',
|
supplierShow: false,
|
disableSubmit: false,
|
numDisable:false,
|
quantityDisable:false,
|
onlyCodeDisable:true,
|
returnShow:false,
|
toolingShow:false,
|
sharpenShow:false,
|
addDisable:false,
|
toolinngOptions:[],
|
title: '操作',
|
visible: false,
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 6 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 18 },
|
},
|
confirmLoading: false,
|
loading: false,
|
form: this.$form.createForm(this),
|
dataSource: [],
|
toolingTreeData:[],
|
warehouseOptions:[],
|
locationOptions:[],
|
allToolingList:[],
|
param: {},
|
barcodeCurrentType: false,
|
planId:'',
|
validatorRules: {
|
planCode: {
|
rules: [
|
{
|
required: true,
|
message: '请输入检验方案编码!',
|
},
|
],
|
},
|
planName: {
|
rules: [
|
{
|
required: true,
|
message: '请输入检验方案名称!',
|
},
|
],
|
},
|
planCategory: {
|
rules: [
|
{
|
required: true,
|
message: '请选择检验方案分类!',
|
},
|
],
|
},
|
},
|
url: {
|
add: '/qms/inspectionPlan/add',
|
edit: '/qms/inspectionPlan/edit',
|
inpspectionItemList:'/qms/inspectionItem/list',
|
detailList:'/qms/inspectionItem/queryList',
|
},
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
width: 50,
|
align: 'center',
|
customRender: function (t, r, index) {
|
return parseInt(index) + 1
|
},
|
},
|
{
|
title: '检验项目编码',
|
align: 'center',
|
dataIndex: 'itemCode',
|
width: 150,
|
},
|
{
|
title: '检验项目名称',
|
align: 'center',
|
dataIndex: 'itemName'
|
},
|
{
|
title: '检验项目分类',
|
align: 'center',
|
dataIndex: 'itemCategoryName',
|
},
|
{
|
title: '定量/定性',
|
align: 'center',
|
dataIndex: 'qualitativeOrQuantitativeName'
|
},
|
{
|
title: '测量工具',
|
align: 'center',
|
dataIndex: 'inspectionToolsNames',
|
},
|
{
|
title: '排序',
|
dataIndex: 'sorter',
|
align: 'center',
|
scopedSlots: { customRender: 'sorter' },
|
},
|
{
|
title: '标准值',
|
dataIndex: 'standardValue',
|
align: 'center',
|
scopedSlots: { customRender: 'standardValue' },
|
},
|
{
|
title: '上公差',
|
dataIndex: 'maxValue',
|
align: 'center',
|
scopedSlots: { customRender: 'maxValue' },
|
},
|
{
|
title: '下公差',
|
dataIndex: 'minValue',
|
align: 'center',
|
scopedSlots: { customRender: 'minValue' },
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
align: 'center',
|
scopedSlots: { customRender: 'action' },
|
},
|
],
|
ruleOptions:[]
|
}
|
},
|
created() {
|
ajaxGetDictItems("qms_sampling_rules,rule_name,id", null).then((res) => {
|
if (res.success) {
|
this.ruleOptions = res.result
|
}
|
})
|
},
|
methods: {
|
|
materialSearch() {
|
this.$refs.materialListModel.openPage()
|
this.$refs.materialListModel.title = '选择物料'
|
this.$refs.materialListModel.disableSubmit = false
|
},
|
getMaterialRows(val) {
|
if (val.materialNumber) {
|
const initialData = {
|
materialNumber: val.materialNumber,
|
materialName: val.materialName
|
};
|
this.form.setFieldsValue(initialData);
|
}
|
|
},
|
handleChange(value, key, column, index) {
|
const temp = [...this.dataSource]
|
const target = temp.filter(item => key === item.key)[index];
|
if (target) {
|
target[column.dataIndex] = value
|
this.dataSource = temp
|
}
|
},
|
modalFormOk() {
|
},
|
getQueryParams() {
|
this.param.pageNo = this.ipagination.current
|
this.param.pageSize = this.ipagination.pageSize
|
return filterObj(this.param)
|
},
|
add() {
|
this.handle = store.getters.userInfo.username
|
this.edit({})
|
},
|
edit(record) {
|
let that = this
|
this.form.resetFields()
|
this.model = Object.assign({}, record)
|
this.visible = true
|
this.isDisabled = false
|
this.disableSubmit = false
|
if (record.id) {
|
this.planId = record.id
|
this.detailList(this.planId)
|
}
|
this.$nextTick(() => {
|
this.form.setFieldsValue(
|
pick(this.model, 'planCode', 'planName', 'planCategory', 'materialNumber', 'materialName','ruleId','planStatus','descreption')
|
)
|
})
|
},
|
close() {
|
this.$emit('close')
|
this.dataSource = []
|
this.visible = false
|
this.supplierShow = false,
|
this.disableSubmit = false,
|
this.numDisable = false,
|
this.quantityDisable = false,
|
this.onlyCodeDisable = true,
|
this.returnShow = false,
|
this.toolingShow = false,
|
this.sharpenShow = false,
|
this.addDisable = false
|
},
|
handleTableChange(pagination, filters, sorter) {
|
this.ipagination = pagination
|
this.detailList(this.planId);
|
},
|
handleOk() {
|
const that = this
|
// 触发表单验证
|
this.form.validateFields((err, values) => {
|
if (!err) {
|
that.confirmLoading = true
|
let formData = Object.assign(this.model, values)
|
formData.detailData = this.dataSource
|
let http = ''
|
if(this.model.id){
|
http = this.url.edit
|
}else{
|
http = this.url.add
|
}
|
postAction(http, formData)
|
.then((res) => {
|
if (res.success) {
|
that.$message.success(res.message)
|
that.$emit('ok', new Date())
|
} else {
|
that.$message.warning(res.message)
|
}
|
})
|
.finally(() => {
|
that.confirmLoading = false
|
that.close()
|
})
|
}
|
})
|
},
|
handleCancel() {
|
this.close()
|
},
|
//选择工具
|
selectInspectionItemList: function () {
|
let ids = []
|
for (let i = 0; i < this.dataSource.length; i++) {
|
ids.push(this.dataSource[i].id)
|
}
|
this.$refs.inspectionItemForm.showModal(ids)
|
this.$refs.inspectionItemForm.title = '选择检验项目'
|
this.$refs.inspectionItemForm.disableSubmit = false
|
},
|
handleDelete(record, index) {
|
this.dataSource.splice(index, 1)
|
},
|
onChange() {},
|
//手选人员值
|
selectCurrentUserChange(e) {
|
console.log('当前手选', e)
|
// this.form.setFieldsValue({
|
// // userName: e,
|
// userNameId: e,
|
// })
|
},
|
detailList(planId) {
|
this.param.planId = planId
|
getAction(this.url.detailList, this.getQueryParams()).then((res) => {
|
if (res.success) {
|
this.dataSource = res.result.records
|
this.ipagination.total = res.result.total;
|
}
|
})
|
},
|
filterOption(input, option) {
|
return (
|
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
);
|
},
|
},
|
watch: {},
|
mounted() {
|
this.$bus.$on('selectionRows', (data) => {
|
//getCurrSelected 事件 接收组件传递的参数
|
for (let i = 0; i < data.length; i++) {
|
this.dataSource.push({
|
id:data[i].id,
|
itemCode: data[i].itemCode,
|
itemName: data[i].itemName,
|
inspectionTools: data[i].inspectionTools,
|
inspectionToolsNames: data[i].inspectionToolsNames,
|
itemCategory: data[i].itemCategory,
|
itemCategoryName:data[i].itemCategoryName,
|
itemStatus:data[i].itemStatus,
|
qualitativeOrQuantitative:data[i].qualitativeOrQuantitative,
|
qualitativeOrQuantitativeName:data[i].qualitativeOrQuantitativeName
|
})
|
}
|
//this.ipaginationm.total = this.dataSource.length
|
})
|
},
|
}
|
</script>
|
|
|
<style lang="less" scoped>
|
.ant-btn {
|
padding: 0 10px;
|
margin-left: 3px;
|
}
|
|
.ant-form-item-control {
|
line-height: 0px;
|
}
|
|
/** 主表单行间距 */
|
.ant-form .ant-form-item {
|
margin-bottom: 10px;
|
}
|
|
/** Tab页面行间距 */
|
.ant-tabs-content .ant-form-item {
|
margin-bottom: 0px;
|
}
|
|
/deep/ .notshow {
|
display: none;
|
}
|
</style>
|