index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight">
  5. <el-col :span="24" class="one">
  6. <c-search :is_search="true" :fields="fields" @search="btSearch"> </c-search>
  7. </el-col>
  8. <el-col :span="24" class="two">
  9. <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @view="toView" @exam="toExam" @export="toExport">
  10. </data-table>
  11. </el-col>
  12. </el-col>
  13. </el-row>
  14. <c-dialog :dialog="dialog" @toClose="toClose">
  15. <template v-slot:info>
  16. <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
  17. <el-form :model="form" :rules="rules" ref="form" label-width="auto">
  18. <el-form-item label="审核状态" prop="status">
  19. <el-select v-model="form.status" clearable filterable placeholder="请选择审核状态" style="width: 100%">
  20. <el-option v-for="(item, index) in statusList" :key="index" :label="item.dict_label" :value="item.dict_value"></el-option>
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="审核意见" prop="remark">
  24. <el-input v-model="form.remark" placeholder="请输入审核意见" type="textarea"></el-input>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button size="small" type="primary" @click="toSubmit('form')">提交审核</el-button>
  28. </el-form-item>
  29. </el-form>
  30. </el-col>
  31. </template>
  32. </c-dialog>
  33. </div>
  34. </template>
  35. <script>
  36. import { mapState, createNamespacedHelpers } from 'vuex';
  37. const { mapActions } = createNamespacedHelpers('studio');
  38. const { mapActions: unitStudioApply } = createNamespacedHelpers('unitStudioApply');
  39. const { mapActions: message } = createNamespacedHelpers('message');
  40. const { mapActions: sysdictdata } = createNamespacedHelpers('sysdictdata');
  41. const moment = require('moment');
  42. export default {
  43. name: 'index',
  44. props: {},
  45. components: {},
  46. data: function () {
  47. return {
  48. searchInfo: {},
  49. fields: [
  50. { label: '序号', options: { type: 'index' } },
  51. { label: '依托单位', model: 'company_name', isSearch: true },
  52. { label: '工作室名称', model: 'name', isSearch: true },
  53. { label: '入驻科学家', model: 'scientist_name', isSearch: true },
  54. { label: '申报日期', model: 'apply_time' },
  55. {
  56. label: '申报状态',
  57. model: 'status',
  58. format: (i) => {
  59. let data = this.statusList.find((r) => r.dict_value == i);
  60. if (data) return data.dict_label;
  61. },
  62. },
  63. ],
  64. opera: [
  65. { label: '详情', method: 'view' },
  66. { label: '审核', method: 'exam', type: 'warning', display: (i) => i.status == '0' },
  67. { label: '导出', method: 'export' },
  68. ],
  69. list: [],
  70. total: 0,
  71. // 领域
  72. fieldList: [],
  73. // 审核状态
  74. statusList: [],
  75. dialog: { title: '信息审核', show: false, type: '1' },
  76. form: {},
  77. rules: {
  78. status: [{ required: true, message: '请选择审核状态', trigger: 'change' }],
  79. remark: [{ required: true, message: '请输入审核意见', trigger: 'blur' }],
  80. },
  81. };
  82. },
  83. async created() {
  84. await this.searchOther();
  85. await this.search();
  86. },
  87. methods: {
  88. ...mapActions(['query', 'update']),
  89. ...unitStudioApply({ CFetch: 'fetch' }),
  90. ...message({ mCreate: 'create' }),
  91. ...sysdictdata({ sQuery: 'query' }),
  92. async search({ skip = 0, limit = this.$limit, ...info } = {}) {
  93. let res = await this.query({ skip, limit, ...info, ...this.searchInfo });
  94. if (this.$checkRes(res)) {
  95. this.$set(this, `list`, res.data);
  96. this.$set(this, `total`, res.total);
  97. }
  98. },
  99. btSearch(query) {
  100. this.$set(this, `searchInfo`, query);
  101. this.search();
  102. },
  103. // 详情
  104. toView({ data }) {
  105. this.$router.push({ path: '/center/studio/info/info', query: { id: data.id } });
  106. },
  107. // 导出
  108. toExport({ data }) {
  109. this.$router.push({
  110. path: '/center/studio/info/export',
  111. query: { id: data._id, company_id: data.company_id, scientistinfo_id: data.scientistinfo_id },
  112. });
  113. },
  114. // 审核
  115. toExam({ data }) {
  116. this.$set(this, `form`, data);
  117. this.dialog = { title: '信息审核', show: true, type: '1' };
  118. },
  119. // 提交审核
  120. toSubmit(formName) {
  121. this.$refs[formName].validate(async (valid) => {
  122. if (valid) {
  123. let data = this.form;
  124. let obj = { id: data._id, status: data.status };
  125. let res = await this.update(obj);
  126. if (this.$checkRes(res, `信息审核成功`, res.errmsg)) this.createMess(data);
  127. } else {
  128. console.log('error submit!!');
  129. return false;
  130. }
  131. });
  132. },
  133. // 发送系统消息
  134. async createMess(data) {
  135. let res = await this.CFetch(data.user_id);
  136. if (this.$checkRes(res)) {
  137. let status = this.statusList.find((r) => r.dict_value == data.status);
  138. if (status) {
  139. let obj = {
  140. user_id: this.user._id,
  141. title: '审核通知',
  142. send_time: moment().format('YYYY-MM-DD HH:mm:ss'),
  143. type: '3',
  144. user: [{ id: data.user_id, company: data.company, phone: res.data.phone }],
  145. content: '您好,您所申报《' + data.name + '》的建设申请,' + status.dict_label + ',原因:' + data.remark,
  146. };
  147. let arr = await this.mCreate(obj);
  148. if (this.$checkRes(arr, `系统信息发送成功`, arr.errmsg)) this.toClose();
  149. }
  150. }
  151. },
  152. // 关闭弹框
  153. toClose() {
  154. this.form = {};
  155. this.dialog = { title: '信息审核', show: false, type: '1' };
  156. this.search();
  157. },
  158. // 查询其他信息
  159. async searchOther() {
  160. let res;
  161. // 申报状态
  162. res = await this.sQuery({ dict_type: 'studio_studio_status' });
  163. if (this.$checkRes(res)) {
  164. this.$set(this, `statusList`, res.data);
  165. }
  166. // 领域
  167. res = await this.sQuery({ dict_type: 'studio_field' });
  168. if (this.$checkRes(res)) {
  169. this.$set(this, `fieldList`, res.data);
  170. }
  171. },
  172. },
  173. computed: {
  174. ...mapState(['user']),
  175. },
  176. metaInfo() {
  177. return { title: this.$route.meta.title };
  178. },
  179. watch: {
  180. test: {
  181. deep: true,
  182. immediate: true,
  183. handler(val) {},
  184. },
  185. },
  186. };
  187. </script>
  188. <style lang="scss" scoped></style>