detail.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <div id="detail">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <el-col :span="24" class="top">
  6. <template>
  7. <el-button type="primary" size="mini" @click="back">返回</el-button>
  8. <el-button type="primary" size="mini" @click="add">添加专家</el-button>
  9. <!-- <el-button type="success" size="mini" @click="previewBtn">预览PDF</el-button> -->
  10. </template>
  11. </el-col>
  12. <el-col :span="24" class="down">
  13. <data-table
  14. :fields="fields"
  15. :opera="opera"
  16. :data="list"
  17. :usePage="false"
  18. @query="search"
  19. @view="toView"
  20. @delete="toDelete"
  21. :useSum="true"
  22. :sumcol="['verify.score']"
  23. sumres="avg"
  24. ></data-table>
  25. </el-col>
  26. </el-col>
  27. </el-row>
  28. <el-dialog title="专家信息管理" width="40%" :visible.sync="dialog" @close="handleClose" :destroy-on-close="true">
  29. <data-form :data="form" :fields="formfields" :rules="rules" @save="toSave">
  30. <template #options="{item}">
  31. <template v-if="item.model === 'expert_id'">
  32. <el-option v-for="(i, index) in expertList" :key="`expert${index}`" :label="i.expert_name" :value="i._id"></el-option>
  33. </template>
  34. </template>
  35. </data-form>
  36. </el-dialog>
  37. <el-dialog title="评分详情" width="40%" :visible.sync="scoreDialog" @close="handleClose" :destroy-on-close="true">
  38. <scoreInfo :form="info"></scoreInfo>
  39. </el-dialog>
  40. </div>
  41. </template>
  42. <script>
  43. const _ = require('lodash');
  44. import scoreInfo from './parts/scoreInfo.vue';
  45. import dataTable from '@common/src/components/frame/filter-page-table.vue';
  46. import dataForm from '@common/src/components/frame/form.vue';
  47. import { mapState, createNamespacedHelpers } from 'vuex';
  48. const { mapActions: achieveExpert } = createNamespacedHelpers('achieveExpert');
  49. const { mapActions: achieveApplyExpert } = createNamespacedHelpers('achieveApplyExpert');
  50. export default {
  51. metaInfo() {
  52. return { title: this.$route.meta.title };
  53. },
  54. name: 'detail',
  55. props: {},
  56. components: {
  57. dataTable,
  58. dataForm,
  59. scoreInfo,
  60. },
  61. data: function() {
  62. return {
  63. // 工作类型:1=>评分;2=>会审
  64. type: '1',
  65. opera: [
  66. // {
  67. // label: '编辑',
  68. // method: 'edit',
  69. // display: i => !_.isObject(i.verify),
  70. // },
  71. {
  72. label: '删除',
  73. method: 'delete',
  74. display: i => !_.isObject(i.verify),
  75. },
  76. {
  77. label: '评分详情',
  78. method: 'view',
  79. display: i => _.isObject(i.verify),
  80. },
  81. ],
  82. fields: [
  83. { label: '专家姓名', prop: 'expert_id.expert_name', showTip: true },
  84. { label: '联系电话', prop: 'expert_id.phone', showTip: true },
  85. { label: '评分', prop: 'verify.score', showTip: true },
  86. { label: '状态', prop: 'verify', format: i => (_.isObject(i) ? '已评分' : '未评分') },
  87. ],
  88. list: [],
  89. total: 0,
  90. // 创建专家账号
  91. dialog: false,
  92. form: {},
  93. rules: {},
  94. formfields: [{ label: '专家', model: 'expert_id', type: 'select', options: { multiple: true } }],
  95. // 评分详情
  96. scoreDialog: false,
  97. info: {},
  98. expertList: [],
  99. };
  100. },
  101. async created() {
  102. await this.search();
  103. this.toGetExpert();
  104. },
  105. methods: {
  106. ...achieveApplyExpert(['query', 'create', 'update', 'delete']),
  107. ...achieveExpert({ getExpert: 'query' }),
  108. // 查询列表
  109. async search({ skip = 0, limit = 10, ...info } = {}) {
  110. const res = await this.query({ ...info, apply_id: this.id, expert: true, type: this.type });
  111. if (this.$checkRes(res)) {
  112. this.$set(this, `list`, res.data);
  113. this.$set(this, `total`, res.total);
  114. }
  115. },
  116. // 专家评分查看
  117. toView({ data }) {
  118. const { expert_id, verify } = data;
  119. const d = { name: expert_id.expert_name, phone: expert_id.phone, score: verify.score, content: verify.content };
  120. this.$set(this, `info`, d);
  121. this.scoreDialog = true;
  122. },
  123. // 添加专家
  124. add() {
  125. this.dialog = true;
  126. },
  127. // 提交
  128. async toSave({ data }) {
  129. const duplicate = _.cloneDeep(data);
  130. duplicate.apply_id = this.id;
  131. duplicate.type = this.type;
  132. let method = _.get(duplicate, '_id') ? 'update' : 'create';
  133. let res = await this[method](duplicate);
  134. if (this.$checkRes(res, '专家保存成功', res.errmsg || '专家保存失败')) {
  135. this.handleClose();
  136. this.search();
  137. }
  138. },
  139. // 修改
  140. // toEdit({ data }) {
  141. // this.$set(this, 'form', _.cloneDeep(data));
  142. // this.dialog = true;
  143. // },
  144. // 删除
  145. async toDelete({ data }) {
  146. const res = await this.delete(data._id);
  147. if (this.$checkRes(res, '删除成功', res.errmsg || '删除失败')) {
  148. this.search();
  149. }
  150. },
  151. // 取消
  152. handleClose() {
  153. this.dialog = false;
  154. this.form = {};
  155. },
  156. // 返回列表
  157. back() {
  158. this.$router.push({ path: '/adminScore' });
  159. },
  160. // 获取专家列表
  161. async toGetExpert() {
  162. const res = await this.getExpert({ status: '0' });
  163. if (this.$checkRes(res)) this.$set(this, 'expertList', res.data);
  164. },
  165. // 预览专家
  166. previewBtn() {
  167. // this.$router.push({ path: '/adminScore/preview', query: { id: this.id, type: '1' } });
  168. },
  169. },
  170. computed: {
  171. ...mapState(['user']),
  172. id() {
  173. return this.$route.query.id;
  174. },
  175. },
  176. watch: {},
  177. };
  178. </script>
  179. <style lang="less" scoped>
  180. .main {
  181. .top {
  182. margin: 0 0 10px 0;
  183. text-align: right;
  184. }
  185. }
  186. </style>