|
@@ -0,0 +1,196 @@
|
|
|
+<template>
|
|
|
+ <a-modal
|
|
|
+ :title="modalTitle"
|
|
|
+ :width="800"
|
|
|
+ :visible="visible"
|
|
|
+ class="ant-modal2"
|
|
|
+ :confirmLoading="confirmLoading"
|
|
|
+ @cancel="handleCancel"
|
|
|
+ @ok='save'
|
|
|
+ >
|
|
|
+ <a-form :form="form">
|
|
|
+ <row-list :col="1">
|
|
|
+ <row-item v-for="(item, index) in data" :key="index">
|
|
|
+ <a-form-item
|
|
|
+ v-show='hiddenFlag'
|
|
|
+ :labelCol="BaseTool.Constant.labelCol"
|
|
|
+ :wrapperCol="BaseTool.Constant.wrapperCol"
|
|
|
+ v-if="item.type === 5"
|
|
|
+ :label="item.label">
|
|
|
+ <a-input v-decorator="[item.fieldName]"/>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item
|
|
|
+ :labelCol="BaseTool.Constant.labelCol"
|
|
|
+ :wrapperCol="BaseTool.Constant.wrapperCol"
|
|
|
+ v-if="item.type === 1 && item.disabledFlag === '0'"
|
|
|
+ :label="item.label">
|
|
|
+ <a-input v-decorator="[item.fieldName, {initialValue: item.value, rules: [{required: item.required, message: '不能为空'}]}]"/>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item
|
|
|
+ :labelCol="BaseTool.Constant.labelCol"
|
|
|
+ :wrapperCol="BaseTool.Constant.wrapperCol"
|
|
|
+ v-if="item.type === 1 && item.disabledFlag === '1'"
|
|
|
+ :label="item.label">
|
|
|
+ <a-input disabled='disabled' v-decorator="[item.fieldName, {initialValue: item.value, rules: [{required: item.required, message: '不能为空'}]}]"/>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item
|
|
|
+ :labelCol="BaseTool.Constant.labelCol"
|
|
|
+ :wrapperCol="BaseTool.Constant.wrapperCol"
|
|
|
+ v-if="item.type === 2"
|
|
|
+ :label="item.label">
|
|
|
+ <a-select
|
|
|
+ v-decorator="[item.fieldName, {initialValue: item.value, rules: [{required: item.required, message: '不能为空'}]}]"
|
|
|
+ style="width: 120px"
|
|
|
+ >
|
|
|
+ <a-select-option
|
|
|
+ v-for="option in item.optionList"
|
|
|
+ :key="option.name"
|
|
|
+ :label="option.name"
|
|
|
+ :value="option.value">{{ option.name }}</a-select-option>
|
|
|
+ </a-select>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item
|
|
|
+ :labelCol="BaseTool.Constant.labelCol"
|
|
|
+ :wrapperCol="BaseTool.Constant.wrapperCol"
|
|
|
+ v-if="item.type === 3"
|
|
|
+ :label="item.label">
|
|
|
+ <a-date-picker
|
|
|
+ v-decorator="[item.fieldName, {initialValue: item.value, rules: [{required: item.required, message: '不能为空'}]}]"
|
|
|
+ style="width: 100%"
|
|
|
+ />
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item
|
|
|
+ :labelCol="BaseTool.Constant.labelCol"
|
|
|
+ :wrapperCol="BaseTool.Constant.wrapperCol"
|
|
|
+ v-if="item.type === 4"
|
|
|
+ :label="item.label">
|
|
|
+ <a-input
|
|
|
+ style="width: 70%"
|
|
|
+ disabled
|
|
|
+ v-decorator="['sbName', {rules: [{required: true, message: '设备不能为空'}]}]" />
|
|
|
+ <a-input type='hidden' v-decorator="['sbId']" />
|
|
|
+ <a-button style="width: 30%" type="primary" @click="sbInfoHandleSelect">选择</a-button>
|
|
|
+ </a-form-item>
|
|
|
+ </row-item>
|
|
|
+ </row-list>
|
|
|
+ </a-form>
|
|
|
+ <sb-info-select-modal ref="sbInfoSelectModal" @selected="sbInfoHandleSelected"/>
|
|
|
+ </a-modal>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
|
|
|
+import { addCustomFieldTemplate, updateCustomFieldTemplate } from '@/api/customize/fieldTemplate'
|
|
|
+import { addCustomFieldTemplateDataForm } from '@/api/customize/fieldTemplateData'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'SbCustomFormView',
|
|
|
+ components: {
|
|
|
+ SbInfoSelectModal
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ confirmLoading: false,
|
|
|
+ modalTitle: null,
|
|
|
+ model: null,
|
|
|
+ data: [],
|
|
|
+ form: this.$form.createForm(this),
|
|
|
+ visible: false,
|
|
|
+ // 下拉框map
|
|
|
+ typeMap: {},
|
|
|
+ typeFieldMap: {},
|
|
|
+ hiddenFlag: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ // 下拉框map
|
|
|
+ this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CUSTOM_FIELD_TEMPLATE_TYPE)
|
|
|
+ this.typeFieldMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CUSTOM_FIELD_TEMPLATE_FILED_TYPE)
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ base (data) {
|
|
|
+ this.visible = true
|
|
|
+ this.modalTitle = '设备报废单'
|
|
|
+ this.data = JSON.parse(data)
|
|
|
+ },
|
|
|
+ setData (values) {
|
|
|
+ const dataList = [...this.data]
|
|
|
+ dataList.forEach((item) => {
|
|
|
+ if (item.type !== 4) {
|
|
|
+ item.value = values[item.fieldName]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return dataList
|
|
|
+ },
|
|
|
+ handleCancel (values) {
|
|
|
+ this.visible = false
|
|
|
+ this.confirmLoading = false
|
|
|
+ this.model = null
|
|
|
+ this.data = []
|
|
|
+ this.form.resetFields()
|
|
|
+ this.$emit('ok', JSON.stringify(values))
|
|
|
+ },
|
|
|
+ handleOk (values) {
|
|
|
+ this.visible = false
|
|
|
+ this.confirmLoading = false
|
|
|
+ this.model = null
|
|
|
+ this.data = []
|
|
|
+ this.form.resetFields()
|
|
|
+ this.$emit('ok', JSON.stringify(values))
|
|
|
+ },
|
|
|
+ sbInfoHandleSelect () {
|
|
|
+ this.$refs.sbInfoSelectModal.base({}, {})
|
|
|
+ },
|
|
|
+ sbInfoHandleSelected (keys, rows) {
|
|
|
+ const [ key ] = keys
|
|
|
+ const [ row ] = rows
|
|
|
+ const { form: { setFieldsValue } } = this
|
|
|
+ // 日期处理
|
|
|
+ this.$nextTick(() => {
|
|
|
+ setFieldsValue(Object.assign({
|
|
|
+ 'sbId': key,
|
|
|
+ 'sbNo': row.no,
|
|
|
+ 'sbName': row.name,
|
|
|
+ 'initialValue': row.initialValue,
|
|
|
+ 'currentValue': row.currentValue,
|
|
|
+ 'startDate': row.startDate,
|
|
|
+ 'workYear': row.workYear,
|
|
|
+ 'id': ''
|
|
|
+ }))
|
|
|
+ })
|
|
|
+ },
|
|
|
+ save () {
|
|
|
+ const { form: { validateFieldsAndScroll } } = this
|
|
|
+ this.confirmLoading = true
|
|
|
+ validateFieldsAndScroll((errors, values) => {
|
|
|
+ if (errors) {
|
|
|
+ this.confirmLoading = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const content = JSON.stringify(values)
|
|
|
+ const obj = {}
|
|
|
+ obj.type = this.DictCache.VALUE.CUSTOM_TEMPLATE_SB_REMARK_NUMBER.ACTIVITY_FORM
|
|
|
+ obj.objId = values.sbId
|
|
|
+ obj.data = content
|
|
|
+ obj.remark = this.DictCache.VALUE.CUSTOM_TEMPLATE_SB_REMARK.SB_SCRAP_FORM
|
|
|
+ // 日期处理
|
|
|
+ if (this.BaseTool.String.isBlank(values.id)) {
|
|
|
+ addCustomFieldTemplateDataForm(obj)
|
|
|
+ .then(() => {
|
|
|
+ this.handleCancel(values)
|
|
|
+ }).catch(() => {
|
|
|
+ this.confirmLoading = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ updateCustomFieldTemplate(values)
|
|
|
+ .then(() => {
|
|
|
+ this.handleCancel(values)
|
|
|
+ }).catch(() => {
|
|
|
+ this.confirmLoading = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|