|
@@ -3,16 +3,20 @@
|
|
|
<el-row>
|
|
|
<el-col :span="24" class="main">
|
|
|
<breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
|
|
|
- <el-col :span="24" class="container"> </el-col>
|
|
|
+ <el-col :span="24" class="container" v-loading="loading">
|
|
|
+ <data-form v-if="!loading" :data="form" :fields="fields" :rules="rules" @save="turnSave"> </data-form>
|
|
|
+ </el-col>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import dataForm from '@/components/frame/form.vue';
|
|
|
import breadcrumb from '@c/common/breadcrumb.vue';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
import bus from '@/components/common/bus';
|
|
|
+const { mapActions: siteinfo } = createNamespacedHelpers('siteinfo');
|
|
|
export default {
|
|
|
metaInfo() {
|
|
|
return { title: this.$route.meta.title };
|
|
@@ -21,12 +25,57 @@ export default {
|
|
|
props: {},
|
|
|
components: {
|
|
|
breadcrumb,
|
|
|
+ dataForm,
|
|
|
},
|
|
|
data: function() {
|
|
|
- return {};
|
|
|
+ return {
|
|
|
+ form: {},
|
|
|
+ fields: [
|
|
|
+ { label: '名称', required: true, model: 'title' },
|
|
|
+ { label: '英文名称', required: true, model: 'engtitle' },
|
|
|
+ { label: '联系方式', required: false, model: 'footinfo', type: 'editor' },
|
|
|
+ ],
|
|
|
+ rules: {
|
|
|
+ title: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
|
|
+ engtitle: [{ required: true, message: '请输入英文名称', trigger: 'blur' }],
|
|
|
+ },
|
|
|
+ loading: true,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ async created() {
|
|
|
+ await this.search();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...siteinfo(['query', 'fetch', 'create', 'update', 'delete']),
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
+ let res = await this.query();
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `form`, res.data[0]);
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async turnSave({ data }) {
|
|
|
+ if (data.id) {
|
|
|
+ let res = await this.update(data);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$message({
|
|
|
+ message: '修改数据成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let res = await this.create(data);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$message({
|
|
|
+ message: '添加数据成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
- created() {},
|
|
|
- methods: {},
|
|
|
computed: {
|
|
|
...mapState(['user']),
|
|
|
},
|