<template>
|
<a-spin :spinning="confirmLoading">
|
|
<!-- <a-tabs v-model="activeKey" @change="handleChangeTabs">-->
|
<!--主表区域 -->
|
<!-- <a-tab-pane tab="设备变动" :key="refKeys[0]" :forceRender="true" :class="'jeecg-tabs-top'" :animated="false">-->
|
<a-form-model ref="form" :model="model" :rules="validatorRules">
|
<a-row>
|
<a-col :xs="24" :sm="24">
|
<a-form-model-item label="单据号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="num">
|
<a-input v-model="model.num" placeholder="请输入单据号" ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<!-- <a-col :xs="24" :sm="12">-->
|
<!-- <a-form-model-item label="审批状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="auditStatus">-->
|
<!-- <j-dict-select-tag type="list" v-model="model.auditStatus" dictCode="audit_status" placeholder="请选择审批状态" disabled/>-->
|
<!-- </a-form-model-item>-->
|
<!-- </a-col>-->
|
<!-- <a-col :xs="24" :sm="12">-->
|
<!-- <a-form-model-item label="变动方式" show="false" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="changeMethod">-->
|
<!-- <a-input v-model="model.changeMethod" placeholder="请输入变动方式" ></a-input>-->
|
<!-- </a-form-model-item>-->
|
<!-- </a-col>-->
|
<a-col :xs="24" :sm="24">
|
<a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
|
<a-textarea v-model="model.remark" rows="4" placeholder="请输入备注" />
|
</a-form-model-item>
|
</a-col>
|
|
</a-row>
|
</a-form-model>
|
|
<!-- </a-tab-pane>-->
|
<!--子表单区域 -->
|
<!-- <a-tab-pane tab="设备报废明细" :key="refKeys[1]" :forceRender="true">-->
|
<!-- <j-editable-table-->
|
<!-- :ref="refKeys[1]"-->
|
<!-- :loading="equipmentScrapDetailTable.loading"-->
|
<!-- :columns="equipmentScrapDetailTable.columns"-->
|
<!-- :dataSource="equipmentScrapDetailTable.dataSource"-->
|
<!-- :maxHeight="300"-->
|
<!-- :rowNumber="true"-->
|
<!-- :rowSelection="true"-->
|
<!-- :actionButton="true"/>-->
|
<!-- </a-tab-pane>-->
|
<a-button
|
type="primary"
|
:style="{ marginRight: '8px',marginBottom:'8px' }"
|
:loading="confirmLoading"
|
@click="selectEquipmentList()"
|
>选择设备</a-button>
|
<a-table
|
ref="table"
|
bordered
|
size="middle"
|
rowKey='id'
|
:columns="columns"
|
:dataSource="dataSource"
|
>
|
<template
|
v-for="col in columns"
|
:slot="col.dataIndex"
|
slot-scope='text, record, index'
|
>
|
<div :key="col.dataIndex">
|
<a-select
|
v-if="col.dataIndex == 'inspectionCycleId'"
|
:value="text"
|
:options="record.inspectionCycles"
|
@change="(e) => handleChange(e, record.key, col, index)"
|
style="width: 100%"
|
:disabled="false"
|
/>
|
</div>
|
</template>
|
|
<span
|
slot="action"
|
slot-scope="text, record, index"
|
>
|
<a-popconfirm
|
title="确定删除吗?"
|
@confirm="() => handleDelete(text,record, index)"
|
>
|
<a>删除</a>
|
</a-popconfirm>
|
</span>
|
</a-table>
|
<template slot="footer">
|
<a-button
|
:style="{marginRight: '8px'}"
|
@click="handleCancel()"
|
>
|
关闭
|
</a-button>
|
|
<a-button
|
@click="handleOk()"
|
type="primary"
|
:loading="confirmLoading"
|
>确定</a-button>
|
</template>
|
<!-- </a-tabs>-->
|
<equipment-select-modal ref="EquipmentSelectModal"></equipment-select-modal>
|
</a-spin>
|
</template>
|
|
<script>
|
|
import { FormTypes,getRefPromise } from '@/utils/JEditableTableUtil'
|
import { JEditableTableModelMixin } from '@/mixins/JEditableTableModelMixin'
|
import { validateDuplicateValue } from '@/utils/util'
|
import { VALIDATE_NO_PASSED, validateFormModelAndTables } from '@/utils/JEditableTableUtil'
|
import EquipmentSelectModal from './EquipmentSelectModal.vue'
|
import pick from 'lodash.pick'
|
import { getAction, postAction, requestPut } from '@api/manage'
|
export default {
|
name: 'EquipmentScrapForm',
|
mixins: [JEditableTableModelMixin],
|
components: {
|
EquipmentSelectModal
|
},
|
data() {
|
return {
|
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 3 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
// 新增时子表默认添加几行空数据
|
// addDefaultRowNum: 1,
|
model:{
|
},
|
validatorRules: {
|
num: [
|
{ required: true, message: '请输入单据号!'},
|
],
|
remark: [
|
{ required: false, message: '请输入备注!'},
|
],
|
},
|
// refKeys: ['equipmentChange','equipmentScrapDetail', ],
|
// tableKeys:['equipmentScrapDetail', ],
|
// activeKey: 'equipmentChange',
|
// // 设备报废明细
|
// equipmentScrapDetailTable: {
|
// loading: false,
|
// dataSource: [],
|
// columns: [
|
// {
|
// title: '设备变动单id',
|
// key: 'equipmentChangeId',
|
// type: FormTypes.hidden,
|
// disabled:true,
|
// width:"200px",
|
// placeholder: '请输入${title}',
|
// defaultValue:'',
|
// },
|
// {
|
// title: '统一编码',
|
// key: 'equipmentId',
|
// type: FormTypes.sel_search,
|
// dictCode:"mom_eam_equipment_account,num,id",
|
// width:"200px",
|
// placeholder: '请输入${title}',
|
// defaultValue:'',
|
// validateRules: [{ required: true, message: '${title}不能为空' }],
|
// },
|
// // {
|
// // title: '统一编码',
|
// // key: 'equipmentNum',
|
// // type: FormTypes.input,
|
// // disabled:true,
|
// // width:"200px",
|
// // placeholder: '请输入${title}',
|
// // defaultValue:'',
|
// // },
|
// {
|
// title: '资产编码',
|
// key: 'assetNumber',
|
// type: FormTypes.input,
|
// disabled:true,
|
// width:"120px",
|
// placeholder: '请输入${title}',
|
// defaultValue:'',
|
// },
|
// {
|
// title: '特种设备',
|
// key: 'specificEquipment',
|
// type: FormTypes.select,
|
// dictCode:"",
|
// disabled:true,
|
// width:"100px",
|
// placeholder: '请输入${title}',
|
// defaultValue:'',
|
// },
|
// {
|
// title: '设备名称',
|
// key: 'equipmentName',
|
// type: FormTypes.input,
|
// disabled:true,
|
// width:"120px",
|
// placeholder: '请输入${title}',
|
// defaultValue:'',
|
// },
|
// {
|
// title: '设备型号',
|
// key: 'model',
|
// type: FormTypes.input,
|
// disabled:true,
|
// width:"120px",
|
// placeholder: '请输入${title}',
|
// defaultValue:'',
|
// },
|
// // {
|
// // title: '设备规格',
|
// // key: 'specification',
|
// // type: FormTypes.input,
|
// // disabled:true,
|
// // width:"200px",
|
// // placeholder: '请输入${title}',
|
// // defaultValue:'',
|
// // },
|
// {
|
// title: '设备状态',
|
// key: 'equipmentStatus',
|
// type: FormTypes.select,
|
// dictCode:"equipment_status",
|
// disabled:true,
|
// width:"120px",
|
// placeholder: '请输入${title}',
|
// defaultValue:'',
|
// },
|
// {
|
// title: '技术状态',
|
// key: 'technologyStatus',
|
// type: FormTypes.select,
|
// dictCode:"technology_status",
|
// disabled:true,
|
// width:"120px",
|
// placeholder: '请输入${title}',
|
// defaultValue:'',
|
// },
|
// {
|
// title: '设备位置',
|
// key: 'location',
|
// type: FormTypes.input,
|
// disabled:true,
|
// width:"200px",
|
// placeholder: '请输入${title}',
|
// defaultValue:'',
|
// },
|
// {
|
// title: '重要度',
|
// key: 'equipmentImportanceId',
|
// type: FormTypes.select,
|
// dictCode:"mom_eam_equipment_importance,name,id",
|
// disabled:true,
|
// width:"120px",
|
// placeholder: '请输入${title}',
|
// defaultValue:'',
|
// },
|
// // {
|
// // title: '设备图片',
|
// // key: 'equipmentPhoto',
|
// // type: FormTypes.image,
|
// // token:true,
|
// // responseName:"message",
|
// // width:"200px",
|
// // placeholder: '请输入${title}',
|
// // defaultValue:'',
|
// // },
|
// {
|
// title: '报废原因',
|
// key: 'scrapReason',
|
// type: FormTypes.input,
|
// width:"200px",
|
// placeholder: '请输入${title}',
|
// defaultValue:'',
|
// },
|
// {
|
// title: '报废日期',
|
// key: 'scrapDate',
|
// type: FormTypes.datetime,
|
// width:"200px",
|
// placeholder: '请输入${title}',
|
// defaultValue:'',
|
// },
|
// ]
|
// },
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key:'rowIndex',
|
width:60,
|
align:"center",
|
customRender:function (t,r,index) {
|
return parseInt(index)+1;
|
}
|
},
|
// {
|
// title:'设备变动单id',
|
// align:"center",
|
// dataIndex: 'equipmentChangeId'
|
// },
|
// {
|
// title:'设备ID',
|
// align:"center",
|
// dataIndex: 'equipmentId_dictText',
|
// },
|
{
|
title:'统一编码',
|
align:"center",
|
dataIndex: 'equipmentNum'
|
},
|
{
|
title:'资产编码',
|
align:"center",
|
dataIndex: 'assetNumber'
|
},
|
{
|
title:'特种设备',
|
align:"center",
|
dataIndex: 'specificEquipment_dictText',
|
},
|
{
|
title:'设备名称',
|
align:"center",
|
dataIndex: 'equipmentName'
|
},
|
{
|
title:'设备型号',
|
align:"center",
|
dataIndex: 'model'
|
},
|
{
|
title:'设备规格',
|
align:"center",
|
dataIndex: 'specification'
|
},
|
{
|
title:'设备状态',
|
align:"center",
|
dataIndex: 'equipmentStatus_dictText',
|
},
|
{
|
title:'技术状态',
|
align:"center",
|
dataIndex: 'technologyStatus_dictText',
|
},
|
{
|
title:'设备位置',
|
align:"center",
|
dataIndex: 'location'
|
},
|
{
|
title:'重要度',
|
align:"center",
|
dataIndex: 'equipmentImportanceId_dictText',
|
},
|
{
|
title:'设备图片',
|
align:"center",
|
dataIndex: 'equipmentPhoto',
|
scopedSlots: {customRender: 'imgSlot'}
|
},
|
{
|
title:'报废原因',
|
align:"center",
|
dataIndex: 'scrapReason'
|
},
|
{
|
title:'报废日期',
|
align:"center",
|
dataIndex: 'scrapDate'
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
align:"center",
|
fixed:"right",
|
width:147,
|
scopedSlots: { customRender: 'action' },
|
},
|
],
|
url: {
|
add: "/eam/equipmentScrap/add",
|
edit: "/eam/equipmentScrap/edit",
|
equipmentChange: {
|
list: '/eam/equipmentScrap/queryById'
|
},
|
equipmentScrapDetail: {
|
list: '/eam/equipmentScrap/queryEquipmentScrapDetailByMainId'
|
},
|
},
|
dataSource: [],
|
}
|
},
|
|
mounted() {
|
this.$bus.$on('selectionRows', (data) => {
|
for (let i = 0; i < data.length; i++) {
|
this.dataSource.push({
|
// id: data[i].id,
|
equipmentId: data[i].id,
|
equipmentNum: data[i].num,
|
equipmentName: data[i].name,
|
|
})
|
}
|
})
|
},
|
|
methods: {
|
// getAllTable() {
|
// let values = this.tableKeys.map(key => getRefPromise(this, key))
|
// return Promise.all(values)
|
// },
|
// /** 调用完edit()方法之后会自动调用此方法 */
|
// editAfter() {
|
// this.$nextTick(() => {
|
// })
|
// // 加载子表数据
|
// if (this.model.id) {
|
// let params = { id: this.model.id }
|
// this.requestSubTableData(this.url.equipmentScrapDetail.list, params, this.equipmentScrapDetailTable)
|
// }
|
// },
|
// //校验所有一对一子表表单
|
// validateSubForm(allValues){
|
// return new Promise((resolve,reject)=>{
|
// Promise.all([
|
// ]).then(() => {
|
// resolve(allValues)
|
// }).catch(e => {
|
// reject(e)
|
// })
|
// })
|
// },
|
// /** 整理成formData */
|
// classifyIntoFormData(allValues) {
|
// let main = Object.assign(this.model, allValues.formValue)
|
// return {
|
// ...main, // 展开
|
// equipmentScrapDetailList: allValues.tablesValue[0].values,
|
// }
|
// },
|
// /** 确定按钮点击事件 */
|
// handleOk() {
|
// /** 触发表单验证 */
|
// this.getAllTable().then(tables => {
|
// return validateFormModelAndTables(this.$refs.form,this.model, tables)
|
// }).then(allValues => {
|
// /** 一次性验证一对一的所有子表 */
|
// return this.validateSubForm(allValues)
|
// }).then(allValues => {
|
// if (typeof this.classifyIntoFormData !== 'function') {
|
// throw this.throwNotFunction('classifyIntoFormData')
|
// }
|
// console.log("this.classifyIntoFormData",typeof this.classifyIntoFormData)
|
// let formData = this.classifyIntoFormData(allValues)
|
//
|
// // 发起请求
|
// return this.request(formData)
|
// }).catch(e => {
|
// if (e.error === VALIDATE_NO_PASSED) {
|
// // 如果有未通过表单验证的子表,就自动跳转到它所在的tab
|
// this.activeKey = e.index == null ? this.refKeys[0] : this.refKeys[e.index+1]
|
// } else {
|
// console.error(e)
|
// }
|
// })
|
// },
|
// validateError(msg){
|
// this.$message.error(msg)
|
// },
|
close() {
|
this.visible = false
|
this.$emit('close')
|
this.$refs.form.clearValidate();
|
},
|
// ********************************************
|
|
//选择设备
|
selectEquipmentList() {
|
let ids = [];
|
for (let i = 0; i < this.dataSource.length; i++) {
|
ids.push(this.dataSource[i].equipmentId);
|
}
|
this.$refs.EquipmentSelectModal.showModals(ids);
|
this.$refs.EquipmentSelectModal.title = '选择设备';
|
this.$refs.EquipmentSelectModal.disableSubmit = false;
|
},
|
|
add() {
|
this.edit({ dailyInspectionStandardDetaillist: [] })
|
|
},
|
|
edit(record) {
|
let that = this;
|
this.getInspectionCycle()
|
that.dataSource = [];
|
this.form.resetFields();
|
this.model = Object.assign({}, record);
|
this.visible = true;
|
if (record.dailyInspectionStandardDetaillist != undefined) {
|
const temp = [...record.dailyInspectionStandardDetaillist];
|
that.dataSource = temp;
|
}
|
that.$nextTick(() => {
|
that.form.setFieldsValue(pick(that.model, 'useId', 'equipmentAccountId', 'remark'));
|
});
|
if (record.id) {
|
this.codeDisable = true;
|
} else {
|
this.codeDisable = false;
|
}
|
},
|
|
close() {
|
this.$emit('close');
|
this.visible = false;
|
},
|
|
handleCancel() {
|
this.close();
|
},
|
|
handleOk() {
|
const that = this;
|
this.form.validateFields((err, values) => {
|
if (!err) {
|
that.confirmLoading = true;
|
let formData = Object.assign(this.model, values);
|
formData.dailyInspectionStandardDetaillist = that.dataSource;
|
let obj;
|
if (!this.model.id) {
|
obj = postAction(this.url.add, formData);
|
} else {
|
obj = requestPut(this.url.edit, formData, { id: this.model.id });
|
}
|
obj.then((res) => {
|
if (res.success) {
|
that.$message.success(res.message);
|
that.$emit('ok');
|
} else {
|
that.$message.warning(res.message);
|
}
|
}).finally(() => {
|
that.confirmLoading = false;
|
that.close();
|
})
|
}
|
})
|
},
|
|
handleDelete(text, record, index) {
|
this.dataSource.splice(index, 1);
|
},
|
|
getInspectionCycle() {
|
getAction(this.url.getInspectionCycle).then((res) => {
|
if (res.success) {
|
this.inspectionCycles = res.result
|
}
|
})
|
},
|
|
handleChange(value, key, column, index) {
|
let that = this;
|
const temp = [...that.dataSource];
|
const target = temp.filter(item => key === item.key)[index];
|
if (target) {
|
if (column.dataIndex == 'inspectionCycleId') {
|
target[column.dataIndex] = value;
|
}
|
//显示带过来的数据
|
that.dataSource = temp;
|
}
|
},
|
}
|
}
|
</script>
|
|
<style scoped>
|
/** tab panel 中有下拉框/日期 这类带下拉效果的,需要加此样式 */
|
/deep/ .jeecg-tabs-top {
|
overflow: visible;
|
}
|
</style>
|