|
@@ -1,255 +1,27 @@
|
|
|
<template>
|
|
|
<div id="index">
|
|
|
- <el-row>
|
|
|
- <el-col :span="24" class="main">
|
|
|
- <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
|
|
|
- <el-col :span="24" class="container info">
|
|
|
- <el-col :span="24" class="top">
|
|
|
- <el-button type="primary" size="mini" @click="dialog = true">添加</el-button>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24" class="list">
|
|
|
- <data-table :fields="fields" :opera="opera" :data="list" :total="total" @edit="toEdit" @delete="toDelete" @query="search"></data-table>
|
|
|
- </el-col>
|
|
|
- </el-col>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-dialog :visible.sync="dialog" title="增加企业信息" @close="toClose" :destroy-on-close="true" width="50%">
|
|
|
- <data-form :data="form" :fields="formFields" :rules="rules" @save="turnSave">
|
|
|
- <!-- 单选 -->
|
|
|
- <!-- <template #radios="{item}">
|
|
|
- <template v-if="item.model === 'type'">
|
|
|
- <el-radio label="0">技术</el-radio>
|
|
|
- <el-radio label="1">产品</el-radio>
|
|
|
- <el-radio label="1">服务</el-radio>
|
|
|
- </template>
|
|
|
- </template> -->
|
|
|
- <!-- 下拉单选 -->
|
|
|
- <!-- <template #options="{item}">
|
|
|
- <template v-if="item.model == 'type'">
|
|
|
- <template v-for="(i, index) in typeList">
|
|
|
- <el-option :key="index" :label="`${i.name}`" :value="i.id"></el-option>
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- <template #custom="{item,form}">
|
|
|
- <template v-if="item.model === 'file'">
|
|
|
- <upload
|
|
|
- :limit="1"
|
|
|
- :data="form.file"
|
|
|
- type="file"
|
|
|
- :isBtn="true"
|
|
|
- :url="`/files/file/upload`"
|
|
|
- @upload="uploadSuccess"
|
|
|
- @onedelete="uploadDeletefile"
|
|
|
- ></upload>
|
|
|
- </template>
|
|
|
- <template v-else-if="item.model === 'video'">
|
|
|
- <upload
|
|
|
- :limit="1"
|
|
|
- :data="form.video"
|
|
|
- type="video"
|
|
|
- :uploadBtn="true"
|
|
|
- listType=""
|
|
|
- :url="`/files/video/upload`"
|
|
|
- @upload="uploadSuccess"
|
|
|
- @onedelete="uploadDeletevideo"
|
|
|
- ></upload>
|
|
|
- </template>
|
|
|
- <template v-else-if="item.model === 'image'">
|
|
|
- <upload
|
|
|
- :limit="2"
|
|
|
- :data="form.image"
|
|
|
- type="image"
|
|
|
- :isBtn="true"
|
|
|
- fileType="2"
|
|
|
- :url="`/files/image/upload`"
|
|
|
- @upload="uploadSuccess"
|
|
|
- @delete="uploadDelete"
|
|
|
- ></upload>
|
|
|
- </template>
|
|
|
- </template> -->
|
|
|
- </data-form>
|
|
|
- </el-dialog>
|
|
|
+ <p>index</p>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import breadcrumb from '@c/common/breadcrumb.vue';
|
|
|
-import dataTable from '@/components/frame/filter-page-table.vue';
|
|
|
-import dataForm from '@/components/frame/form.vue';
|
|
|
-import upload from '@/components/frame/uploadone.vue';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
-const { mapActions: testmess } = createNamespacedHelpers('testmess');
|
|
|
export default {
|
|
|
- metaInfo() {
|
|
|
- return { title: this.$route.meta.title };
|
|
|
- },
|
|
|
name: 'index',
|
|
|
props: {},
|
|
|
- components: {
|
|
|
- breadcrumb,
|
|
|
- dataTable,
|
|
|
- dataForm,
|
|
|
- // upload,
|
|
|
- },
|
|
|
+ components: {},
|
|
|
data: function() {
|
|
|
- return {
|
|
|
- opera: [
|
|
|
- {
|
|
|
- label: '修改',
|
|
|
- icon: 'el-icon-edit',
|
|
|
- method: 'edit',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '删除',
|
|
|
- icon: 'el-icon-delete',
|
|
|
- method: 'delete',
|
|
|
- },
|
|
|
- ],
|
|
|
- fields: [
|
|
|
- { label: '标题', prop: 'title' },
|
|
|
- { label: '发布时间', prop: 'publish_time' },
|
|
|
- { label: '来源', prop: 'origin' },
|
|
|
- { label: '内容', prop: 'content' },
|
|
|
- ],
|
|
|
- list: [],
|
|
|
- total: 0,
|
|
|
- // 增加菜单
|
|
|
- dialog: false,
|
|
|
- formFields: [
|
|
|
- { label: '标题', required: true, model: 'title' },
|
|
|
- { label: '发布时间', required: true, model: 'publish_time', type: 'date' },
|
|
|
- { label: '来源', required: true, model: 'origin' },
|
|
|
- { label: '内容', required: true, model: 'content' },
|
|
|
- ],
|
|
|
- form: {},
|
|
|
- rules: {},
|
|
|
- // 类型
|
|
|
- typeList: [
|
|
|
- {
|
|
|
- id: '0',
|
|
|
- name: '技术',
|
|
|
- },
|
|
|
- {
|
|
|
- id: '1',
|
|
|
- name: '产品',
|
|
|
- },
|
|
|
- {
|
|
|
- id: '2',
|
|
|
- name: '服务',
|
|
|
- },
|
|
|
- ],
|
|
|
- };
|
|
|
- },
|
|
|
- created() {
|
|
|
- this.search();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- ...testmess(['query', 'fetch', 'create', 'update', 'delete']),
|
|
|
- // 查询列表
|
|
|
- async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
- let res = await this.query({ skip, limit, ...info });
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- this.$set(this, `list`, res.data);
|
|
|
- this.$set(this, `total`, res.total);
|
|
|
- }
|
|
|
- },
|
|
|
- // 修改
|
|
|
- async toEdit({ data }) {
|
|
|
- this.dialog = true;
|
|
|
- let res = await this.fetch(data.id);
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- this.$set(this, `form`, res.data);
|
|
|
- }
|
|
|
- },
|
|
|
- // 删除
|
|
|
- async toDelete() {
|
|
|
- let res = await this.delete(data);
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- this.$message({
|
|
|
- message: '删除成功',
|
|
|
- type: 'success',
|
|
|
- });
|
|
|
- this.search();
|
|
|
- }
|
|
|
- },
|
|
|
- // 增加菜单
|
|
|
- // 保存
|
|
|
- async turnSave({ data }) {
|
|
|
- if (data.id) {
|
|
|
- let res = await this.update(data);
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- this.$message({
|
|
|
- message: '修改成功',
|
|
|
- type: 'success',
|
|
|
- });
|
|
|
- this.toClose();
|
|
|
- } else {
|
|
|
- this.$message({
|
|
|
- message: res.errmsg,
|
|
|
- type: 'error',
|
|
|
- });
|
|
|
- }
|
|
|
- } else {
|
|
|
- let res = await this.create(data);
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- this.$message({
|
|
|
- message: '创建成功',
|
|
|
- type: 'success',
|
|
|
- });
|
|
|
- this.toClose();
|
|
|
- } else {
|
|
|
- this.$message({
|
|
|
- message: res.errmsg,
|
|
|
- type: 'error',
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- // 取消增加
|
|
|
- toClose() {
|
|
|
- this.form = {};
|
|
|
- this.dialog = false;
|
|
|
- this.search();
|
|
|
- },
|
|
|
- uploadSuccess({ type, data }) {
|
|
|
- if (type == 'image') {
|
|
|
- let arr = _.get(this.form, type);
|
|
|
- if (_.isArray(arr)) {
|
|
|
- let datas = { name: data.name, url: data.uri };
|
|
|
- this.form[type].push({ name: data.name, url: data.uri });
|
|
|
- } else {
|
|
|
- let newArr = [{ name: data.name, url: data.uri }];
|
|
|
- this.$set(this.form, `${type}`, newArr);
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$set(this.form, `${type}`, data.uri);
|
|
|
- }
|
|
|
- },
|
|
|
- // 删除图片
|
|
|
- uploadDelete(index) {
|
|
|
- this.form.image.splice(index, 1);
|
|
|
- },
|
|
|
- uploadDeletefile(data) {
|
|
|
- this.form.file = null;
|
|
|
- },
|
|
|
- uploadDeletevideo(data) {
|
|
|
- this.form.video = null;
|
|
|
- },
|
|
|
+ return {};
|
|
|
},
|
|
|
+ created() {},
|
|
|
+ methods: {},
|
|
|
computed: {
|
|
|
...mapState(['user']),
|
|
|
},
|
|
|
+ metaInfo() {
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
+ },
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="less" scoped>
|
|
|
-.main {
|
|
|
- .info {
|
|
|
- .top {
|
|
|
- text-align: right;
|
|
|
- margin: 10px 0;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-</style>
|
|
|
+<style lang="less" scoped></style>
|