| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <template>
- <el-dialog
- v-if="visible"
- :title="form.id?'编辑物务资源目录':'新建物务资源目录'"
- :visible.sync="visible"
- width="600px"
- append-to-body
- >
- <el-form v-loading="isLoading" :model="form" label-width="100px" label-position="top">
- <el-row :gutter="16">
- <el-col :span="8">
- <el-form-item label="字段编码">
- <el-input v-model="form.fieldKey" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="字段名称">
- <el-input v-model="form.fieldLabel" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="排序">
- <el-input-number v-model="form.sortNumber" :min="0" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item label="默认值">
- <el-radio v-model="form.fieldType" label="string">文本</el-radio>
- <el-radio v-model="form.fieldType" label="number">数字</el-radio>
- <el-radio v-model="form.fieldType" label="bool">布尔</el-radio>
- <el-radio v-model="form.fieldType" label="bstring">多行文本</el-radio>
- <el-radio v-model="form.fieldType" label="radio">单选框</el-radio>
- <el-radio v-model="form.fieldType" label="checkbox">多选框</el-radio>
- <el-radio v-model="form.fieldType" label="select">下拉选择</el-radio>
- </el-form-item>
- <el-form-item label="默认值">
- <el-input v-model="form.defaultValue" type="textarea" />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="visible = false">取 消</el-button>
- <el-button type="primary" @click="handleSubmit">确 定</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- import { save, updateById } from '@/api/base/category_extend_column'
- import { Message } from 'element-ui'
- export default {
- data() {
- return {
- visible: false,
- isLoading: false,
- form: {},
- dataTypeId: null
- }
- },
- mounted() {
- },
- methods: {
- open(data, dataTypeId) {
- this.visible = true
- this.isLoading = false
- this.form = {}
- console.log(data, dataTypeId)
- this.form = Object.assign({}, data)
- if (this.form.fieldType) {
- this.form.fieldType = this.form.fieldType.name
- }
- this.dataTypeId = dataTypeId
- },
- handleSubmit() {
- const param = {
- ...this.form,
- 'dataTypeId': this.dataTypeId
- }
- if ((!param.defaultValue || param.defaultValue === '') && (param.fieldType === 'radio' || param.fieldType === 'checkbox' || param.fieldType === 'select')) {
- Message({
- message: '单选框、多选框、下拉选择的数据类型必需填写默认值,多个值请用英文逗号(“,”)分隔',
- type: 'error',
- duration: 5 * 1000
- })
- return
- }
- this.isLoading = true
- console.log(param)
- if (this.form.id) {
- updateById(this.form.id, param).then(() => {
- this.visible = false
- this.$emit('ok')
- }).finally(() => {
- this.isLoading = false
- })
- } else {
- save(param).then(res => {
- this.visible = false
- this.$emit('ok')
- }).finally(() => {
- this.isLoading = false
- })
- }
- }
- }
- }
- </script>
|