12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <template>
- <div>
- <el-dialog
- v-loading="loading"
- :show-close="false"
- :close-on-click-modal="false"
- :visible.sync="isShow"
- :title="curObj.id ? '编辑问答' : '新增问答'"
- :fullscreen="false"
- width="700px"
- custom-class="xl-dialog"
- center
- >
- <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="110px">
- <div slot="footer" style="padding-top: 20px;">
- <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
- <el-button class="xl-form-btn t1" @click="close('confirm')">确定</el-button>
- </div>
- </base-form>
- </el-dialog>
- </div>
- </template>
- <script>
- export default {
- components: { },
- mixins,
- props: {
- isShow: Boolean,
- curObj: Object
- },
- inject: ['parentData'],
- data() {
- return {
- formData: [],
- loading: true,
- cObj: {},
- isShowMap: false
- }
- },
- watch: {
- isShow: function(val) {
- if (val) {
- this.getDef()
- }
- },
- },
- methods: {
- getDef() {
- let disabled = false
- if (this.curObj.id) disabled = true
- this.formData = [
- { label: '标签', key: 'question_tag', rules: 1, type: 'select', options: this.$dictData.question_tag },
- { label: '问题', key: 'question_cont', type: 'textarea', rules: 1 },
- { label: '答案', key: 'answer_cont', type: 'textarea', rules: 1 },
- ]
- },
- close(str) {
- if (str === 'confirm') {
- this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
- if (valid) {
- const oldform = this.$refs.ruleForm.baseForm
- const newForm = { ...oldform }
- if (this.curObj.id) {
- newForm.id = this.curObj.id
- }
- let apiStr = 'admqaadd'
- // newForm.question_tag = newForm.question_tag.join(',')
- if (newForm.id) apiStr = 'admqaedit'
- this.$api.other[apiStr](newForm).then(data => {
- this.$msgs(newForm.id ? '编辑成功' : '新增成功')
- this.$emit('close', newForm)
- })
- }
- })
- } else {
- this.$emit('close')
- this.setDefaultValue()
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @import '../../../../styles/libEdit.scss';
- .lib-edit {
- padding-top: 0;
- ::v-deep .el-form-item {
- margin-bottom: 10px;
- }
- ::v-deep .el-date-editor.el-input {
- width: 100%;
- }
- }
- </style>
|