detail.vue 5.3 KB

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