123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <template>
- <div id="index">
- <list-frame title="问卷列表页" @query="search" :total="total" :filter="filFields" @add="$router.push({ path: '/questionnaire/detail' })">
- <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" @delete="toDelete"></data-table>
- </list-frame>
- </div>
- </template>
- <script>
- import listFrame from '@frame/layout/admin/list-frame';
- import dataTable from '@frame/components/data-table';
- import { createNamespacedHelpers } from 'vuex';
- const { mapActions: questionnaire } = createNamespacedHelpers('questionnaire');
- export default {
- name: 'index',
- props: {},
- components: {
- listFrame,
- dataTable,
- },
- data: () => ({
- opera: [
- {
- label: '编辑',
- icon: 'el-icon-edit',
- method: 'edit',
- },
- {
- label: '删除',
- icon: 'el-icon-delete',
- method: 'delete',
- },
- ],
- fields: [
- { label: '问卷序号', prop: 'num' },
- { label: '问卷标题', prop: 'name' },
- ],
- filFields: [
- { label: '问卷名', model: 'name' },
- { label: '问卷序号', model: 'id' },
- ],
- list: [],
- total: 0,
- }),
- created() {
- this.search();
- },
- computed: {},
- methods: {
- ...questionnaire(['query', 'delete']),
- async search({ skip = 0, limit = 10, ...info } = {}) {
- const res = await this.query({ skip, limit, ...info });
- if (this.$checkRes(res)) {
- this.$set(this, `list`, res.data);
- this.$set(this, `total`, res.total);
- }
- },
- toEdit({ data }) {
- this.$router.push({ path: '/questionnaire/detail', query: { id: data.id } });
- },
- async toDelete({ data }) {
- const res = await this.delete(data.id);
- this.$checkRes(res, '删除成功', '删除失败');
- this.search();
- },
- },
- };
- </script>
- <style lang="less" scoped></style>
|