|
@@ -2,37 +2,124 @@
|
|
<div id="index">
|
|
<div id="index">
|
|
<el-row>
|
|
<el-row>
|
|
<el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
<el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
- <el-col :span="24" class="one">系统首页</el-col>
|
|
|
|
|
|
+ <el-col :span="24" class="one">
|
|
|
|
+ <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch">
|
|
|
|
+ <template #is_use>
|
|
|
|
+ <el-option v-for="i in is_useList" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
|
+ </template>
|
|
|
|
+ </cSearch>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24" class="two">
|
|
|
|
+ <cButton @toAdd="toAdd()"> </cButton>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24" class="thr">
|
|
|
|
+ <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @edit="toEdit" @del="toDel"> </cTable>
|
|
|
|
+ </el-col>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
-
|
|
|
|
-<script setup lang="ts">
|
|
|
|
-// 基础
|
|
|
|
|
|
+<script lang="ts" setup>
|
|
|
|
+import _ from 'lodash';
|
|
import type { Ref } from 'vue';
|
|
import type { Ref } from 'vue';
|
|
-// reactive,
|
|
|
|
-import { onMounted, ref, getCurrentInstance } from 'vue';
|
|
|
|
|
|
+import { ref, onMounted, getCurrentInstance } from 'vue';
|
|
|
|
+import { useRouter } from 'vue-router';
|
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
|
+import store from '@/stores/counter';
|
|
// 接口
|
|
// 接口
|
|
-//import { TestStore } from '@common/src/stores/test';
|
|
|
|
-//import type { IQueryResult } from '@/util/types.util';
|
|
|
|
-//const testAxios = TestStore();
|
|
|
|
|
|
+import { DockImgtxtStore } from '@common/src/stores/allAdmin/dockImgtxt';
|
|
|
|
+import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
|
|
|
|
+import type { IQueryResult } from '@/util/types.util';
|
|
|
|
+const dockImgtxt = DockImgtxtStore();
|
|
|
|
+const dictData = DictDataStore();
|
|
|
|
+
|
|
const { proxy } = getCurrentInstance() as any;
|
|
const { proxy } = getCurrentInstance() as any;
|
|
|
|
+
|
|
|
|
+// 路由
|
|
|
|
+const router = useRouter();
|
|
|
|
+let user: Ref<any> = ref({});
|
|
// 加载中
|
|
// 加载中
|
|
-const loading: Ref<any> = ref(false);
|
|
|
|
-// 分页数据
|
|
|
|
-// const skip = 0;
|
|
|
|
-// const limit = proxy.limit;;
|
|
|
|
-// 请求
|
|
|
|
|
|
+const loading = ref(false);
|
|
|
|
+// 列表数据
|
|
|
|
+let list: Ref<any> = ref([]);
|
|
|
|
+// 总数
|
|
|
|
+let total: Ref<number> = ref(0);
|
|
|
|
+let skip = 0;
|
|
|
|
+let limit: number = proxy.$limit;
|
|
|
|
+// 列表
|
|
|
|
+let fields: Ref<any[]> = ref([
|
|
|
|
+ { label: '内容', model: 'content', isSearch: true },
|
|
|
|
+ { label: '状态', model: 'is_use', format: (i) => getDict(i, 'is_use'), isSearch: true, type: 'select' }
|
|
|
|
+]);
|
|
|
|
+// 操作
|
|
|
|
+let opera: Ref<any[]> = ref([
|
|
|
|
+ { label: '修改', method: 'edit' },
|
|
|
|
+ { label: '删除', method: 'del', confirm: true, type: 'danger' }
|
|
|
|
+]);
|
|
|
|
+// 查询数据
|
|
|
|
+let searchForm: Ref<any> = ref({});
|
|
|
|
+// 字典表
|
|
|
|
+let is_useList: Ref<any> = ref([]);
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
loading.value = true;
|
|
loading.value = true;
|
|
- // await search({ skip, limit });
|
|
|
|
|
|
+ user.value = store.state.user;
|
|
|
|
+ await searchOther();
|
|
|
|
+ await search({ skip, limit });
|
|
loading.value = false;
|
|
loading.value = false;
|
|
});
|
|
});
|
|
-//const search = async (e: { skip: number; limit: number }) => {
|
|
|
|
-// const info = { skip: e.skip, limit: e.limit, ...searchInfo.value };
|
|
|
|
-// const res: IQueryResult = await testAxios.query(info);
|
|
|
|
-// console.log(res);
|
|
|
|
-//};
|
|
|
|
|
|
+// 查询
|
|
|
|
+const search = async (e: { skip: number; limit: number }) => {
|
|
|
|
+ const { skip, limit } = e;
|
|
|
|
+ const condition = _.cloneDeep(searchForm.value);
|
|
|
|
+ let info = { limit: limit, skip: skip, ...condition, dock_id: user.value._id };
|
|
|
|
+ let res: IQueryResult = await dockImgtxt.query(info);
|
|
|
|
+ if (res.errcode == 0) {
|
|
|
|
+ list.value = res.data;
|
|
|
|
+ total.value = res.total;
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+const toSearch = (query) => {
|
|
|
|
+ searchForm.value = query;
|
|
|
|
+ search({ skip, limit });
|
|
|
|
+};
|
|
|
|
+const getDict = (e, model) => {
|
|
|
|
+ if (model == 'is_use') {
|
|
|
|
+ let data: any = is_useList.value.find((i: any) => i.value == e);
|
|
|
|
+ if (data) return data.label;
|
|
|
|
+ else return '暂无';
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 添加
|
|
|
|
+const toAdd = () => {
|
|
|
|
+ router.push({ path: '/imgtxt/detail' });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const toEdit = (data) => {
|
|
|
|
+ router.push({ path: '/imgtxt/detail', query: { id: data._id } });
|
|
|
|
+};
|
|
|
|
+// 删除
|
|
|
|
+const toDel = async (data) => {
|
|
|
|
+ let res: IQueryResult = await dockImgtxt.del(data._id);
|
|
|
|
+ if (res.errcode == 0) {
|
|
|
|
+ ElMessage({ type: `success`, message: `刪除信息成功` });
|
|
|
|
+ search({ skip, limit });
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+const searchOther = async () => {
|
|
|
|
+ let res: IQueryResult;
|
|
|
|
+ // 状态
|
|
|
|
+ res = await dictData.query({ type: 'common_use' });
|
|
|
|
+ if (res.errcode == 0) is_useList.value = res.data;
|
|
|
|
+};
|
|
</script>
|
|
</script>
|
|
-<style scoped lang="scss"></style>
|
|
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+.main {
|
|
|
|
+ .one {
|
|
|
|
+ margin: 0 0 10px 0;
|
|
|
|
+ }
|
|
|
|
+ .two {
|
|
|
|
+ margin: 0 0 10px 0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|