610 lines
23 KiB
Java
610 lines
23 KiB
Java
<template>
|
|
<a-spin :spinning="confirmLoading" style="width: 100%">
|
|
<a-form-model :model="formInline" v-if="isFormInline" class="formAdd" :rules="rules" ref="ruleForm1">
|
|
<a-row :gutter="24">
|
|
<div v-for="(item,index) in dataList" :key="index">
|
|
<a-col :span="12" v-if="item.field_show_type === '1'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<!-- <span :class="{'title-text-text':false}">{{item.db_field_en_name}}</span><br>-->
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel" :prop="item.db_field_name">
|
|
<a-input class="box-input" v-model="formInline[item.db_field_name]"
|
|
:disabled="disabled"
|
|
:placeholder="$t('PleaseEnter')+item.db_field_txt"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
|
|
<a-col :span="12" v-else-if="item.field_show_type === '2'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<!-- <span :class="{'title-text-text':false}">{{item.db_field_en_name}}</span><br>-->
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel-multi" :prop="item.db_field_name">
|
|
<j-multi-select-tag class="box-input" v-model="formInline[item.db_field_name]"
|
|
:disabled="disabled"
|
|
:placeholder="$t('PleaseSelect')+item.db_field_txt" :type="'checkbox'"
|
|
:triggerChange="false" :dictCode="item.dict_field"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
|
|
<a-col :span="12" v-else-if="item.field_show_type === '5'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<!-- <span :class="{'title-text-text':false}">{{item.db_field_en_name}}</span><br>-->
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel" :prop="item.db_field_name">
|
|
<a-date-picker class="box-input" v-model="formInline[item.db_field_name]"
|
|
@change="dateChange(item)"
|
|
:getCalendarContainer="(trigger) => trigger.parentNode"
|
|
format="YYYY-MM-DD"
|
|
:disabled="disabled"
|
|
style="width: 100%"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
|
|
<a-col :span="12" v-else-if="item.field_show_type === '6'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<!-- <span :class="{'title-text-text':false}">{{item.db_field_en_name}}</span><br>-->
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel" :prop="item.db_field_name">
|
|
<a-range-picker v-model="formInline[item.db_field_name]"
|
|
:disabled="disabled"
|
|
@change="onChange(item.db_field_name)"></a-range-picker>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
|
|
<a-col :span="12" v-else-if="item.field_show_type === '2'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<!-- <span :class="{'title-text-text':false}">{{item.db_field_en_name}}</span><br>-->
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel" :prop="item.db_field_name">
|
|
<a-input-number class="box-input"
|
|
:disabled="disabled"
|
|
v-model="formInline[item.db_field_name]" :min="1" :max="99999999"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
|
|
<a-col :span="12" v-else-if="item.field_show_type === '3'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<!-- <span :class="{'title-text-text':false}">{{item.db_field_en_name}}</span><br>-->
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel" :prop="item.db_field_name">
|
|
<j-dict-select-tag class="box-input" v-model="formInline[item.db_field_name]"
|
|
:disabled="disabled"
|
|
:placeholder="$t('PleaseSelect')+item.db_field_txt" :type="'select'"
|
|
:triggerChange="false" :dictCode="item.dict_field"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
|
|
<a-col :span="12" v-else-if="item.field_show_type === '4'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<!-- <span :class="{'title-text-text':false}">{{item.db_field_en_name}}</span><br>-->
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel-multi" :prop="item.db_field_name">
|
|
<j-multi-select-tag class="box-input" v-model="formInline[item.db_field_name]"
|
|
:disabled="disabled"
|
|
:placeholder="$t('PleaseSelect')+item.db_field_txt" :type="'select'"
|
|
:triggerChange="false" :dictCode="item.dict_field"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
|
|
<a-col :span="12" v-else-if="item.field_show_type === 'RADIO'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<!-- <span :class="{'title-text-text':false}">{{item.db_field_en_name}}</span><br>-->
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel" :prop="item.db_field_name">
|
|
<j-dict-select-tag v-model="formInline[item.db_field_name]" :placeholder="$t('PleaseSelect')+item.db_field_txt"
|
|
:disabled="disabled"
|
|
:type="'radio'" :triggerChange="false" :dictCode="item.dict_field"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
|
|
<a-col :span="12" v-else-if="item.field_show_type === '8'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<!-- <span :class="{'title-text-text':false}">{{item.db_field_en_name}}</span><br>-->
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel" :prop="item.db_field_name">
|
|
<a-textarea :placeholder="$t('PleaseSelect')+item.db_field_txt"
|
|
:disabled="disabled"
|
|
v-model="formInline[item.db_field_name]" :rows="4"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
<a-col :span="12" v-else-if="item.field_show_type === 'treeSelect'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<!-- <span :class="{'title-text-text':false}">{{item.db_field_en_name}}</span><br>-->
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel" :prop="item.db_field_name">
|
|
<a-tree-select
|
|
tree-node-filter-prop="title"
|
|
v-model="formInline[item.db_field_name]"
|
|
style="width: 100%"
|
|
:maxTagCount="1"
|
|
:getPopupContainer="triggerNode=> triggerNode.parentNode"
|
|
:tree-data="treeData"
|
|
tree-checkable
|
|
placeholder="Please select"
|
|
/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
<a-col :span="12" v-else-if="item.field_show_type === '7'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<!-- <span :class="{'title-text-text':false}">{{item.db_field_en_name}}</span><br>-->
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel" :prop="item.db_field_name">
|
|
<uploadFile ref="uploadFile" :accept="accept" :disabled="disabled" @uploadSuccess="uploadSuccess"></uploadFile>
|
|
<!-- <a-button type="primary" class="button-text"-->
|
|
<!-- @click="clickButtonToUpload(item.db_field_name)">-->
|
|
<!-- {{ (formInline[item.db_field_name] === 'null' || formInline[item.db_field_name] === '' ||-->
|
|
<!-- formInline[item.db_field_name] == null) ? $t('clickUpload') : $t('viewUploadedFiles')-->
|
|
<!-- }}-->
|
|
<!-- </a-button>-->
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
|
|
<a-col :span="12" v-else-if="item.field_show_type === '9'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<span class="title-text-text" :title="item.db_field_txt">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel" :prop="item.db_field_name">
|
|
<PersonnelSelection :query="item"
|
|
:disabled="disabled"
|
|
v-model="formInline[item.db_field_name]"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
|
|
<a-col :span="12" v-else-if="item.field_show_type === '10'">
|
|
<div class="box-title-text">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<!-- <span :class="{'title-text-text':false}">{{item.db_field_en_name}}</span><br>-->
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel" :prop="item.db_field_name">
|
|
<Standardselection :query="item"
|
|
:disabled="disabled"
|
|
:standard="formInline"
|
|
:standardId="formInline[item.db_field_name+'_id']"
|
|
@change="StandardselectionChange"
|
|
v-model="formInline[item.db_field_name]"/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
|
|
<a-col :span="12" v-else-if="item.field_show_type === '0'">
|
|
<div class="box-title-text" :title="item.db_field_txt">
|
|
<div class="title-text">
|
|
<span class="Required" v-if="item.field_must_input == 1">*</span>
|
|
<span class="title-text-text">{{item.db_field_txt}}</span>
|
|
</div>
|
|
<a-form-model-item class="itemModel" :prop="item.db_field_name">
|
|
<a-tree-select
|
|
tree-node-filter-prop="title"
|
|
v-model="formInline[item.db_field_name]"
|
|
:maxTagCount="1"
|
|
style="width: 100%"
|
|
:tree-data="item.tree"
|
|
:getPopupContainer="triggerNode=> triggerNode.parentNode"
|
|
tree-checkable
|
|
:placeholder="$t('PleaseSelect')+item.db_field_txt"
|
|
/>
|
|
</a-form-model-item>
|
|
</div>
|
|
</a-col>
|
|
</div>
|
|
</a-row>
|
|
|
|
</a-form-model>
|
|
</a-spin>
|
|
</template>
|
|
|
|
<script>
|
|
import uploadFile from '@/components/OcrUpload/index'
|
|
import PersonnelSelection from '@/components/PersonnelSelection/index'
|
|
import Standardselection from '@/components/Standardselection/index'
|
|
import { getAction, postAction } from '@/api/manage'
|
|
import axios from 'axios'
|
|
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
|
import eventBUs from '../../common/event'
|
|
import moment from 'moment'
|
|
import Vue from 'vue'
|
|
|
|
export default {
|
|
name: 'SplitBatForm',
|
|
components: {
|
|
uploadFile,
|
|
Standardselection,
|
|
PersonnelSelection
|
|
},
|
|
props: {
|
|
url: {
|
|
type: Object,
|
|
default: {}
|
|
},
|
|
flag: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
// accept:{
|
|
// type:String,
|
|
// },
|
|
ids: {
|
|
type:String,
|
|
default:''
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
formInline: {},
|
|
isFormInline: false,
|
|
rules: {},
|
|
labelCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 6 }
|
|
},
|
|
wrapperCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 17 }
|
|
},
|
|
dataList: [],
|
|
ruleList: [],
|
|
validatorRules: {},
|
|
confirmLoading: false,
|
|
uploadName: 'attId',
|
|
accept:'application/pdf',
|
|
token:Vue.ls.get(ACCESS_TOKEN),
|
|
}
|
|
},
|
|
mounted() {
|
|
this.getForm()
|
|
// console.log('idssss111',this.ids)
|
|
},
|
|
methods: {
|
|
StandardselectionChange(value, id) {
|
|
this.formInline[value + '_id'] = id
|
|
this.formInline = { ...this.formInline }
|
|
},
|
|
sumber() {
|
|
// console.log('vilidate',this.formInline)
|
|
this.$refs.ruleForm1.validate(valid => {
|
|
if (valid) {
|
|
let url = ''
|
|
if (this.formInline.id) {
|
|
url = this.url.updateInfo
|
|
} else {
|
|
url = this.url.addInfo
|
|
}
|
|
// console.log('res',this.ids)
|
|
let formInline = JSON.parse(JSON.stringify(this.formInline))
|
|
|
|
Object.keys(formInline).forEach(res => {
|
|
if (formInline[res] instanceof Array) {
|
|
formInline[res] = formInline[res].join(',')
|
|
}
|
|
})
|
|
formInline.ids=this.ids
|
|
axios({
|
|
url: url,
|
|
method: 'post',
|
|
data: formInline,
|
|
headers: {
|
|
'X-Access-Token':this.token
|
|
}
|
|
})
|
|
.then( (res) => {
|
|
if(res.data.success){
|
|
this.$message.success(this.$t('OperationSuccessful'))
|
|
// this.loadData()
|
|
this.$emit('addFormClick')
|
|
// eventBUs.$emit('searchReset')
|
|
}else{
|
|
this.$message.warning(this.$t('operationFailed'))
|
|
}
|
|
})
|
|
} else {
|
|
return false
|
|
}
|
|
})
|
|
},
|
|
clickButtonToUpload(current) {
|
|
this.$refs.uploadFile.visible = true
|
|
// this.uploadName = current
|
|
},
|
|
/** 上传文件的回调 */
|
|
uploadSuccess(data) {
|
|
// console.log(data)
|
|
let attIdList = []
|
|
if(data && data.length>0){
|
|
data.map(item => {
|
|
attIdList.push(item.id || data.name)
|
|
})
|
|
/** 赋值给当前对应的表单文件 */
|
|
this.formInline[this.uploadName] = attIdList.join(',')
|
|
this.formInline = { ...this.formInline }
|
|
// console.log('form',this.formInline)
|
|
}else{
|
|
this.formInline[this.uploadName]=''
|
|
this.formInline = { ...this.formInline }
|
|
// console.log('form',this.formInline)
|
|
|
|
}
|
|
},
|
|
handleInput(value) {
|
|
this.$nextTick(() => {
|
|
this.formInline = { ...this.formInline }
|
|
this.$refs.ruleForm1.validateField([value])
|
|
})
|
|
},
|
|
IntegrateData() {
|
|
this.isFormInline = false
|
|
let rules = {}
|
|
this.ruleList.forEach((res, index) => {
|
|
const rule = []
|
|
if (res.field_must_input == 1) {
|
|
if (res.field_show_type === '1') {
|
|
rule.push({
|
|
required: true,
|
|
message: res.db_field_txt + this.$t('cannotEmpty'),
|
|
trigger: 'blur'
|
|
})
|
|
// if(res.db_field_name=='standNumber'){
|
|
// rule.push(
|
|
// { min:1, max: 200, message: this.$t('cantExeed')+'200'+this.$t('characters'), trigger: 'blur' },
|
|
// )
|
|
// }else if(res.db_field_name=='standName'){
|
|
// rule.push(
|
|
// { min:1, max: 200, message: this.$t('cantExeed')+'200'+this.$t('characters'), trigger: 'blur' },
|
|
// )
|
|
// }
|
|
|
|
} else if (res.field_show_type === 'CHECKBOX' || res.field_show_type === 'list_multi' ||
|
|
res.field_show_type === 'date' || res.field_show_type === 'file') {
|
|
rule.push({
|
|
required: true,
|
|
message: res.db_field_txt + this.$t('cannotEmpty'),
|
|
trigger: 'change'
|
|
})
|
|
} else if (res.field_show_type === 'NUMBER') {
|
|
rule.push({
|
|
required: true,
|
|
message: res.db_field_txt + this.$t('cannotEmpty'),
|
|
trigger: 'blur'
|
|
})
|
|
} else if (res.field_show_type === 'TEXTAREA') {
|
|
rule.push({
|
|
required: true,
|
|
message: res.db_field_txt + this.$t('cannotEmpty'),
|
|
trigger: 'blur'
|
|
})
|
|
} else if (res.field_show_type === 'RADIO' || res.field_show_type === '3') {
|
|
rule.push({
|
|
required: true,
|
|
message: res.db_field_txt + this.$t('cannotEmpty'),
|
|
trigger: 'change'
|
|
})
|
|
}else if (res.field_show_type === '7') {
|
|
rule.push({
|
|
required: true,
|
|
message: res.db_field_txt + this.$t('cannotEmpty'),
|
|
trigger: 'change',
|
|
})
|
|
}else if (res.field_show_type === '0') {
|
|
rule.push({
|
|
required: true,
|
|
message: res.db_field_txt + this.$t('cannotEmpty'),
|
|
trigger: 'change',
|
|
})
|
|
}
|
|
}
|
|
if (res.field_show_type === '1' ||
|
|
res.field_show_type === '8' || res.field_show_type === '9' || res.field_show_type === '10'
|
|
|| res.field_show_type === '11') {
|
|
rule.push({
|
|
max: res.db_length,
|
|
message: res.db_field_txt + this.$t('cantExeed') + res.db_length + this.$t('characters'),
|
|
trigger: 'blur'
|
|
})
|
|
}
|
|
if (rule.length > 0) {
|
|
rules[res.db_field_name] = rule
|
|
}
|
|
})
|
|
// console.log(rules)
|
|
this.$set(this, 'rules', rules)
|
|
this.isFormInline = true
|
|
this.confirmLoading = false
|
|
},
|
|
getForm() {
|
|
this.confirmLoading = true
|
|
let params = {
|
|
flag: this.flag
|
|
}
|
|
getAction(this.url.getAddForm, params).then((res) => {
|
|
if (res.success) {
|
|
this.dataList = res.result
|
|
this.ruleList = res.result
|
|
this.IntegrateData()
|
|
}
|
|
})
|
|
},
|
|
dateChange(item) {
|
|
this.formInline[item.db_field_name] = moment(this.formInline[item.db_field_name]).format('YYYY-MM-DD')
|
|
},
|
|
onChange(item) {
|
|
let dateOne = moment(this.formInline[item][0]).format('YYYY-MM-DD')
|
|
let dateTwo = moment(this.formInline[item][1]).format('YYYY-MM-DD')
|
|
this.formInline[item] = [dateOne, dateTwo]
|
|
},
|
|
edit(item) {
|
|
getAction(this.url.getDocumentInfo, { id: item.id }).then((res) => {
|
|
if (res.success) {
|
|
this.formInline = res.result[0]
|
|
}
|
|
})
|
|
},
|
|
add(){
|
|
this.formInline = {}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style>
|
|
.formAdd .ant-form-item-label {
|
|
width: 130px;
|
|
}
|
|
|
|
.formAdd .ant-form-item-control-wrapper {
|
|
display: inline-block;
|
|
width: 100%;
|
|
}
|
|
|
|
/*.formAdd .ant-form-item {*/
|
|
/* margin-bottom: 20px;*/
|
|
/*}*/
|
|
|
|
.itemModel .ant-form-item-control-wrapper {
|
|
width: 100%;
|
|
}
|
|
|
|
.box-input .ant-select-selection--single {
|
|
height: 38px;
|
|
}
|
|
|
|
.box-input .ant-select-selection--multiple {
|
|
height: 38px;
|
|
}
|
|
|
|
.box-input .ant-select-selection__rendered {
|
|
line-height: 38px;
|
|
height: 38px;
|
|
}
|
|
|
|
.box-input .ant-select-selection--multiple .ant-select-selection__rendered > ul > li {
|
|
margin-top: 6px;
|
|
}
|
|
|
|
.box-input .ant-calendar-picker {
|
|
line-height: 38px;
|
|
height: 38px;
|
|
}
|
|
|
|
.box-input .ant-calendar-picker-input {
|
|
height: 38px;
|
|
}
|
|
|
|
.box-input .ant-input-number-input-wrap {
|
|
line-height: 38px;
|
|
height: 38px;
|
|
}
|
|
</style>
|
|
<style scoped>
|
|
.box-title-text {
|
|
line-height: 1.4;
|
|
display: flex;
|
|
/*align-items: center;*/
|
|
}
|
|
|
|
.title-text {
|
|
width: 90px;
|
|
text-align: right;
|
|
display: inline-block;
|
|
/*font-weight: bold;*/
|
|
font-size: 14px;
|
|
margin-right: 16px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.box-input {
|
|
display: inline-block;
|
|
height: 38px;
|
|
width: 100%;
|
|
}
|
|
|
|
.itemModel {
|
|
width: calc(100% - 130px);
|
|
display: inline-block;
|
|
margin-top: 2px;
|
|
}
|
|
|
|
.Required {
|
|
color: red;
|
|
margin-right: 4px;
|
|
}
|
|
|
|
.title-text-text {
|
|
margin-top: 11px;
|
|
display: inline-block;
|
|
}
|
|
|
|
.header-text {
|
|
font-size: 16px;
|
|
font-weight: bold;
|
|
margin-left: 15px;
|
|
/*border-bottom: 1px #d9d9d9 dashed;*/
|
|
height: 30px;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.formAdd {
|
|
/*margin-bottom: 40px;*/
|
|
}
|
|
|
|
.button-text {
|
|
height: 38px;
|
|
width: calc(100% - 120px);
|
|
line-height: 38px;
|
|
background: #fff;
|
|
border: 1px #00B3BE solid;
|
|
color: #00B3BE;
|
|
}
|
|
</style> |