Pārlūkot izejas kodu

Merge branch 'master' of http://git.cc-lotus.info/studio_vue3/jcyjdt_studio

zs 2 gadi atpakaļ
vecāks
revīzija
0e5a1b3610
1 mainītis faili ar 170 papildinājumiem un 168 dzēšanām
  1. 170 168
      src/views/center/studio/year/index.vue

+ 170 - 168
src/views/center/studio/year/index.vue

@@ -3,197 +3,199 @@
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight">
         <el-col :span="24" class="one">
-          <c-search :is_search="true" :fields="fields" @search="btSearch">
+          <component :is="partsSearch" :is_search="true" :fields="fields" @search="partSearch">
             <template #status>
               <el-option v-for="i in statusList" :key="i.model" :label="i.dict_label" :value="i.dict_value"></el-option>
             </template>
             <template #studio_id>
               <el-option v-for="i in studioList" :key="i.id" :label="i.name" :value="i.id"></el-option>
             </template>
-          </c-search>
+          </component>
         </el-col>
         <el-col :span="24" class="two">
-          <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @exam="toExam">
+          <component
+            :is="CTable"
+            :fields="fields"
+            :opera="opera"
+            :select="false"
+            :selected="selected"
+            @handleSelect="handleSelect"
+            @query="search"
+            :data="tableData"
+            :total="total"
+            @exam="toExam"
+          >
             <template #file="{ row, item }">
               <el-link v-for="(i, index) in row[item.model]" :key="index" :href="i.url" target="_blank">{{ i.name }}</el-link>
             </template>
-          </data-table>
+          </component>
         </el-col>
       </el-col>
     </el-row>
-    <c-dialog :dialog="dialog" @toClose="toClose">
+    <component :is="CDialog" :dialog="dialog" @handleClose="handleClose">
       <template v-slot:info>
-        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
-          <el-form :model="form" :rules="rules" ref="form" label-width="auto">
-            <el-form-item label="审核状态" prop="status">
-              <el-select v-model="form.status" clearable filterable placeholder="请选择审核状态" style="width: 100%">
-                <el-option v-for="(item, index) in statusList" :key="index" :label="item.dict_label" :value="item.dict_value"></el-option>
-              </el-select>
-            </el-form-item>
-            <el-form-item label="审核意见" prop="remark">
-              <el-input v-model="form.remark" placeholder="请输入审核意见" type="textarea"></el-input>
-            </el-form-item>
-            <el-form-item>
-              <el-button size="small" type="primary" @click="toSubmit('form')">提交审核</el-button>
-            </el-form-item>
-          </el-form>
-        </el-col>
+        <component :is="CForm" :fields="infoFields" :rules="rules" :form="form" labelWidth="auto" @save="toSave">
+          <template #status>
+            <el-option v-for="(item, index) in statusList" :key="index" :label="item.dict_label" :value="item.dict_value"></el-option>
+          </template>
+        </component>
       </template>
-    </c-dialog>
+    </component>
   </div>
 </template>
 
-<script>
-import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions } = createNamespacedHelpers('yearreport');
-const { mapActions: studio } = createNamespacedHelpers('studio');
-const { mapActions: sysdictdata } = createNamespacedHelpers('sysdictdata');
-const { mapActions: message } = createNamespacedHelpers('message');
-const { mapActions: unitStudioApply } = createNamespacedHelpers('unitStudioApply');
-const moment = require('moment');
-export default {
-  name: 'index',
-  props: {},
-  components: {},
-  data: function () {
-    return {
-      // 查询
-      searchInfo: {},
-      fields: [
-        { label: '序号', options: { type: 'index' } },
-        {
-          label: '工作室名称',
-          model: 'studio_id',
-          type: 'select',
-          format: (i) => {
-            let data = this.studioList.find((r) => r.id == i);
-            if (data) return data.name;
-          },
-          isSearch: true,
-        },
-        { label: '依托单位名称', model: 'company_name' },
-        { label: '申请时间', model: 'apply_time' },
-        { label: '报告文件', model: 'file', custom: true },
-        {
-          label: '审核状态',
-          model: 'status',
-          type: 'select',
-          format: (i) => {
-            let data = this.statusList.find((r) => r.dict_value == i);
-            if (data) return data.dict_label;
-          },
-          isSearch: true,
-        },
-      ],
-      opera: [{ label: '审核', method: 'exam', type: 'warning', display: (i) => i.status == '0' }],
-      list: [],
-      total: 0,
-      // 工作室列表
-      studioList: [],
-      // 审核状态
-      statusList: [],
-      dialog: { title: '信息审核', show: false, type: '1' },
-      form: {},
-      rules: {
-        status: [{ required: true, message: '请选择审核状态', trigger: 'change' }],
-        remark: [{ required: true, message: '请输入审核意见', trigger: 'blur' }],
-      },
-    };
-  },
-  created() {
-    this.searchOther();
-    this.search();
-  },
-  methods: {
-    ...mapActions(['query', 'update']),
-    ...studio({ sQuery: 'query' }),
-    ...sysdictdata({ dQuery: 'query' }),
-    ...message({ mCreate: 'create' }),
-    ...unitStudioApply({ CFetch: 'fetch' }),
-    async search({ skip = 0, limit = this.$limit, ...info } = {}) {
-      if (this.studio_id) info.studio_id = this.studio_id;
-      let res = await this.query({ skip, limit, ...info, ...this.searchInfo });
-      if (this.$checkRes(res)) {
-        this.$set(this, `list`, res.data);
-        this.$set(this, `total`, res.total);
-      }
-    },
-    btSearch(query) {
-      this.$set(this, `searchInfo`, query);
-      this.search();
-    },
-    // 信息审核
-    toExam({ data }) {
-      this.$set(this, `form`, data);
-      this.dialog = { title: '信息审核', show: true, type: '1' };
-    },
-    // 提交审核
-    toSubmit(formName) {
-      this.$refs[formName].validate(async (valid) => {
-        if (valid) {
-          let data = this.form;
-          let obj = { id: data.id, status: data.status };
-          let res = await this.update(obj);
-          if (this.$checkRes(res, `信息审核成功`, res.errmsg)) this.createMess(data);
-        } else {
-          console.log('error submit!!');
-          return false;
-        }
-      });
-    },
-    // 发送系统消息
-    async createMess(data) {
-      let res = await this.CFetch(data.user_id);
-      if (this.$checkRes(res)) {
-        let obj = {
-          user_id: this.user._id,
-          title: '审核通知',
-          send_time: moment().format('YYYY-MM-DD HH:mm:ss'),
-          type: '3',
-          user: [{ id: data.user_id, company: data.company_name, phone: res.data.phone }],
-          content: '您好,您所上传《' + data.studio_name + '》的年度报告,' + `${data.status == '1' ? '已通过审核' : '未通过审核'}` + ',原因:' + data.remark,
-        };
-        let arr = await this.mCreate(obj);
-        if (this.$checkRes(arr, `系统信息发送成功`, arr.errmsg)) this.toClose();
-      }
-    },
-    // 关闭弹框
-    toClose() {
-      this.form = {};
-      this.dialog = { title: '信息审核', show: false, type: '1' };
-      this.search();
-    },
-    // 查詢其他信息
-    async searchOther() {
-      let res;
-      // 工作室
-      res = await this.sQuery({ status: '7' });
-      if (this.$checkRes(res)) {
-        this.$set(this, `studioList`, res.data);
-      }
-      // 审核状态
-      res = await this.dQuery({ dict_type: 'studio_status' });
-      if (this.$checkRes(res)) {
-        this.$set(this, `statusList`, res.data);
-      }
-    },
-  },
-  computed: {
-    ...mapState(['user']),
-    studio_id() {
-      return this.$route.query.studio_id;
+<script lang="ts" setup>
+import store from '@/stores/counter';
+import moment from 'moment';
+// #region 组件
+import partsSearch from '@/components/c-search.vue';
+import CTable from '@/components/c-table.vue';
+import CForm from '@/components/c-form.vue';
+import CDialog from '@/components/c-dialog.vue';
+// #endregion
+import type { Ref } from 'vue';
+import { ref, onMounted, getCurrentInstance, reactive } from 'vue';
+import type { FormRules } from 'element-plus';
+import { ElMessage } from 'element-plus';
+// #region 接口
+import { YearreportStore } from '@common/src/stores/studio/studios/yearreport'; // 列表
+import { StudioStore } from '@common/src/stores/studio/studios/studio'; // 列表
+import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
+import { MessageStore } from '@common/src/stores/studio/other/message'; // 系统消息
+import { UnitStudioApplyStore } from '@common/src/stores/studio/role/unitStudioApply';
+import type { IQueryResult } from '@/util/types.util';
+const yearreport = YearreportStore();
+const studio = StudioStore();
+const sysdictdata = DictDataStore();
+const message = MessageStore();
+const unitStudioApply = UnitStudioApplyStore();
+const { proxy } = getCurrentInstance() as any;
+// #endregion
+// 列表数据
+let tableData: Ref<any[]> = ref([]);
+// 列表
+let fields: Ref<any[]> = ref([
+  { label: '序号', options: { type: 'index' } },
+  {
+    label: '工作室名称',
+    model: 'studio_id',
+    type: 'select',
+    format: (i) => {
+      let data = studioList.value.find((r) => r.id == i);
+      if (data) return data.name;
     },
+    isSearch: true,
   },
-  metaInfo() {
-    return { title: this.$route.meta.title };
-  },
-  watch: {
-    test: {
-      deep: true,
-      immediate: true,
-      handler(val) {},
+  { label: '依托单位名称', model: 'company_name' },
+  { label: '申请时间', model: 'apply_time' },
+  { label: '报告文件', model: 'file', custom: true },
+  {
+    label: '审核状态',
+    model: 'status',
+    type: 'select',
+    format: (i) => {
+      let data = statusList.value.find((r) => r.dict_value == i);
+      if (data) return data.dict_label;
     },
+    isSearch: true,
   },
+]);
+// 操作
+let opera: Ref<any[]> = ref([{ label: '审核', method: 'exam', type: 'warning', display: (i) => i.status == '0' }]);
+// 多选
+let selected: Ref<any[]> = ref([]);
+// 总数
+let total: Ref<number> = ref(0);
+let skip = 0;
+let limit: number = proxy.$limit;
+// 查询数据
+let searchForm: Ref<{}> = ref({});
+// 弹框
+const dialog: Ref<{ type: string; show: boolean; title: string }> = ref({ type: '1', show: false, title: '信息管理' });
+// 审核表单
+let form: Ref<{}> = ref({});
+// 必填项
+const rules = reactive<FormRules>({
+  status: [{ required: true, message: '请选择审核状态', trigger: 'change' }],
+  remark: [{ required: true, message: '请输入审核意见', trigger: 'blur' }],
+});
+// 表单
+let infoFields: Ref<any[]> = ref([
+  { label: '审核状态', model: 'status', type: 'select' },
+  { label: '审核意见', model: 'remark', type: 'textarea' },
+]);
+// 状态
+let statusList: Ref<any[]> = ref([]);
+let studioList: Ref<any[]> = ref([]);
+onMounted(async () => {
+  await searchOther();
+  await search({ skip, limit });
+});
+// 查询
+const search = async (e: { skip: number; limit: number }) => {
+  const { skip, limit } = e;
+  let info = { limit: limit, skip: skip, ...searchForm.value };
+  const res: IQueryResult = await yearreport.query(info);
+  tableData.value = res.data as any[];
+  total.value = res.total;
+};
+// 查询
+const partSearch = (form: { [x: string]: any }) => {
+  searchForm.value = form;
+  search({ skip, limit });
+};
+
+// 审核
+const toExam = (data: object) => {
+  form.value = data;
+  dialog.value = { title: '信息管理', show: true, type: '1' };
+};
+// 审核保存
+const toSave = async (data: { _id: string; status: string }) => {
+  let obj = { id: data._id, status: data.status };
+  let res: IQueryResult = await yearreport.update(obj);
+  if (res.errcode == 0) {
+    ElMessage({ type: 'success', message: '维护信息成功' });
+    createMess(data);
+  } else ElMessage({ type: 'warning', message: `${res.errmsg}` });
+};
+// // 发送系统消息
+const createMess = async (data) => {
+  let user = store.state.user;
+  let res = await unitStudioApply.fetch(data.unit_id);
+  if (res.errcode == 0) {
+    let obj = {
+      user_id: user._id,
+      title: '审核通知',
+      send_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+      type: '3',
+      user: [{ id: data.user_id, company: data.company_name, phone: res.data.phone }],
+      content: '您好,您所上传《' + data.studio_name + '》的年度报告,' + `${data.status == '1' ? '已通过审核' : '未通过审核'}` + ',原因:' + data.remark,
+    };
+    let arr = await message.create(obj);
+    if (arr.errcode == 0) {
+      ElMessage({ type: 'success', message: '系统信息发送成功' });
+      handleClose();
+    }
+  }
+};
+
+// 关闭弹窗
+const handleClose = () => {
+  form.value = {};
+  search({ skip, limit });
+  dialog.value = { title: '信息管理', show: false, type: '' };
+};
+// 选择
+const handleSelect = () => {};
+// 查询其他信息
+const searchOther = async () => {
+  // 字典表---审核状态
+  const p1: IQueryResult = await sysdictdata.query({ dict_type: 'studio_status' });
+  statusList.value = p1.data as [];
+  // 工作室
+  const p2 = await studio.query({ status: '7' });
+  studioList.value = p2.data as [];
 };
 </script>