|
@@ -8,10 +8,10 @@
|
|
|
<el-col :span="24" class="list">
|
|
|
<el-tabs v-model="active" type="card">
|
|
|
<el-tab-pane label="未参加" name="first">
|
|
|
- <data-table :fields="fields" :opera="opera" :data="oneList" :total="oneTotal" @query="search" @view="toView"></data-table>
|
|
|
+ <data-table :fields="fields" :opera="opera" :data="oneList" :total="oneTotal" @query="data => search(data, false)" @add="toAdd"></data-table>
|
|
|
</el-tab-pane>
|
|
|
<el-tab-pane label="已参加" name="second">
|
|
|
- <data-table :fields="fields" :opera="twoopera" :data="twoList" :total="twoTotal" @query="search" @view="toView"></data-table>
|
|
|
+ <data-table :fields="fields" :opera="opera" :data="twoList" :total="twoTotal" @query="data => search(data, true)" @edit="toEdit"></data-table>
|
|
|
</el-tab-pane>
|
|
|
</el-tabs>
|
|
|
</el-col>
|
|
@@ -44,6 +44,8 @@ import dataTable from '@/components/data-table.vue';
|
|
|
import questionInfo from './parts/questionInfo.vue';
|
|
|
import projectForm from './parts/projectForm.vue';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: question } = createNamespacedHelpers('question');
|
|
|
+const { mapActions: projectsolic } = createNamespacedHelpers('projectsolic');
|
|
|
export default {
|
|
|
metaInfo() {
|
|
|
return { title: this.$route.meta.title };
|
|
@@ -64,13 +66,13 @@ export default {
|
|
|
opera: [
|
|
|
{
|
|
|
label: '添加项目征集信息',
|
|
|
- method: 'view',
|
|
|
+ method: 'add',
|
|
|
+ display: i => !i.exist,
|
|
|
},
|
|
|
- ],
|
|
|
- twoopera: [
|
|
|
{
|
|
|
label: '修改项目征集信息',
|
|
|
- method: 'view',
|
|
|
+ method: 'edit',
|
|
|
+ display: i => i.exist,
|
|
|
},
|
|
|
],
|
|
|
fields: [
|
|
@@ -79,22 +81,10 @@ export default {
|
|
|
{ label: '发布时间', prop: 'create_date' },
|
|
|
],
|
|
|
// 未参加
|
|
|
- oneList: [
|
|
|
- {
|
|
|
- title: '标题',
|
|
|
- origin: '信息来源',
|
|
|
- create_date: '创建时间',
|
|
|
- },
|
|
|
- ],
|
|
|
+ oneList: [],
|
|
|
oneTotal: 0,
|
|
|
// 已参加
|
|
|
- twoList: [
|
|
|
- {
|
|
|
- title: '标题',
|
|
|
- origin: '信息来源',
|
|
|
- create_date: '创建时间',
|
|
|
- },
|
|
|
- ],
|
|
|
+ twoList: [],
|
|
|
twoTotal: 0,
|
|
|
// 添加,修改
|
|
|
formActive: 'first',
|
|
@@ -104,19 +94,51 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
async created() {
|
|
|
- await this.search();
|
|
|
+ await this.search({}, true);
|
|
|
+ await this.search({}, false);
|
|
|
},
|
|
|
methods: {
|
|
|
- async search() {
|
|
|
- console.log();
|
|
|
+ ...question({ questionQuery: 'query' }),
|
|
|
+ ...projectsolic(['query', 'create', 'update', 'delete']),
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}, exist) {
|
|
|
+ const res = await this.questionQuery({ skip, limit, ...info, exist, user_id: this.user.uid });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ let type = 'one';
|
|
|
+ if (exist) type = 'two';
|
|
|
+ this.$set(this, `${type}List`, res.data);
|
|
|
+ this.$set(this, `${type}Total`, res.total);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ toAdd({ data }) {
|
|
|
+ this.display = 'detail';
|
|
|
+ this.$set(this, 'info', data);
|
|
|
+ this.form.question_id = data._id;
|
|
|
+ this.form.user_id = this.user.uid;
|
|
|
},
|
|
|
- // 添加,修改信息
|
|
|
- toView({ data }) {
|
|
|
+ async toEdit({ data }) {
|
|
|
+ const res = await this.query({ question_id: data._id, user_id: this.user.uid });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ const data = _.head(res.data);
|
|
|
+ if (!data) throw new Error('未找到要修改的数据');
|
|
|
+ this.$set(this, 'form', data);
|
|
|
+ }
|
|
|
this.display = 'detail';
|
|
|
+ this.$set(this, 'info', data);
|
|
|
},
|
|
|
// 提交保存
|
|
|
- onSubmit({ data }) {
|
|
|
- console.log(data);
|
|
|
+ async onSubmit({ data }) {
|
|
|
+ const dup = _.cloneDeep(data);
|
|
|
+ let res;
|
|
|
+ if (dup.id) {
|
|
|
+ res = await this.update(dup);
|
|
|
+ } else {
|
|
|
+ res = await this.create(dup);
|
|
|
+ }
|
|
|
+ if (this.$checkRes(res, '保存成功', res.errmsg || '保存失败')) {
|
|
|
+ this.search({}, true);
|
|
|
+ this.search({}, false);
|
|
|
+ this.back();
|
|
|
+ }
|
|
|
},
|
|
|
// 返回列表
|
|
|
back() {
|