You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

317 lines
9.6 KiB

  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. </el-form>
  5. <el-row :gutter="10" class="mb8">
  6. <el-col :span="1.5">
  7. <el-button
  8. type="primary"
  9. plain
  10. icon="el-icon-plus"
  11. size="mini"
  12. @click="handleAdd"
  13. v-hasPermi="['vet:experts:add']"
  14. >新增</el-button>
  15. </el-col>
  16. <el-col :span="1.5">
  17. <el-button
  18. type="success"
  19. plain
  20. icon="el-icon-edit"
  21. size="mini"
  22. :disabled="single"
  23. @click="handleUpdate"
  24. v-hasPermi="['vet:experts:edit']"
  25. >修改</el-button>
  26. </el-col>
  27. <el-col :span="1.5">
  28. <el-button
  29. type="danger"
  30. plain
  31. icon="el-icon-delete"
  32. size="mini"
  33. :disabled="multiple"
  34. @click="handleDelete"
  35. v-hasPermi="['vet:experts:remove']"
  36. >删除</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="warning"
  41. plain
  42. icon="el-icon-download"
  43. size="mini"
  44. @click="handleExport"
  45. v-hasPermi="['vet:experts:export']"
  46. >导出</el-button>
  47. </el-col>
  48. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  49. </el-row>
  50. <el-table v-loading="loading" :data="expertsList" @selection-change="handleSelectionChange">
  51. <el-table-column type="selection" width="55" align="center" />
  52. <el-table-column label="真实姓名" align="center" prop="realName" />
  53. <el-table-column label="联系电话" align="center" prop="iphone" />
  54. <el-table-column label="电子邮箱" align="center" prop="email" />
  55. <el-table-column label="职称" align="center" prop="title" />
  56. <el-table-column label="从业经验" align="center" prop="workExperience" />
  57. <el-table-column label="专家类型" align="center" prop="expert" />
  58. <el-table-column label="擅长领域" align="center" prop="expertiseArea" />
  59. <el-table-column label="工作单位" align="center" prop="address" />
  60. <el-table-column label="在线状态" align="center" prop="isOnline" />
  61. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  62. <template slot-scope="scope">
  63. <el-button
  64. size="mini"
  65. type="text"
  66. icon="el-icon-chat-dot-round"
  67. @click="handleConsultation(scope.row)"
  68. v-hasPermi="['system:consultation:view']"
  69. >咨询</el-button>
  70. <el-button
  71. size="mini"
  72. type="text"
  73. icon="el-icon-edit"
  74. @click="handleUpdate(scope.row)"
  75. v-hasPermi="['vet:experts:edit']"
  76. >修改</el-button>
  77. <el-button
  78. size="mini"
  79. type="text"
  80. icon="el-icon-delete"
  81. @click="handleDelete(scope.row)"
  82. v-hasPermi="['vet:experts:remove']"
  83. >删除</el-button>
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. <pagination
  88. v-show="total>0"
  89. :total="total"
  90. :page.sync="queryParams.pageNum"
  91. :limit.sync="queryParams.pageSize"
  92. @pagination="getList"
  93. />
  94. <!-- 添加或修改专家信息对话框 -->
  95. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  96. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  97. <el-form-item label="真实姓名" prop="realName">
  98. <el-input v-model="form.realName" placeholder="请输入真实姓名" />
  99. </el-form-item>
  100. <el-form-item label="擅长领域" prop="expertiseArea">
  101. <el-input v-model="form.expertiseArea" placeholder="请输入擅长领域" />
  102. </el-form-item>
  103. <el-form-item label="联系方式" prop="contactInfo">
  104. <el-input v-model="form.contactInfo" type="textarea" placeholder="请输入内容" />
  105. </el-form-item>
  106. <el-form-item label="在线状态" prop="isOnline">
  107. <el-select v-model="form.isOnline" placeholder="请选择在线状态" clearable>
  108. <el-option v-for="dict in dict.type.is_online" :key="dict.value" :label="dict.label" :value="dict.value" />
  109. </el-select>
  110. </el-form-item>
  111. </el-form>
  112. <div slot="footer" class="dialog-footer">
  113. <el-button type="primary" @click="submitForm"> </el-button>
  114. <el-button @click="cancel"> </el-button>
  115. </div>
  116. </el-dialog>
  117. <!-- 专家咨询对话框 -->
  118. <el-dialog
  119. :title="`专家咨询 - ${selectedExpertName}`"
  120. :visible.sync="consultationDialogVisible"
  121. width="90%"
  122. top="5vh"
  123. append-to-body>
  124. <consultation-component
  125. :expert-id="selectedExpertId"
  126. :expert-name="selectedExpertName"
  127. v-if="consultationDialogVisible"
  128. />
  129. <div slot="footer" class="dialog-footer">
  130. <el-button @click="consultationDialogVisible = false"> </el-button>
  131. </div>
  132. </el-dialog>
  133. </div>
  134. </template>
  135. <script>
  136. import { listExperts, getExperts, delExperts, addExperts, updateExperts } from "@/api/vet/experts"
  137. import ConsultationComponent from '@/views/system/consultation/index.vue'
  138. export default {
  139. name: "Experts",
  140. dicts: ['is_online'],
  141. components: {
  142. ConsultationComponent
  143. },
  144. data() {
  145. return {
  146. // 遮罩层
  147. loading: true,
  148. // 选中数组
  149. ids: [],
  150. // 非单个禁用
  151. single: true,
  152. // 非多个禁用
  153. multiple: true,
  154. // 显示搜索条件
  155. showSearch: true,
  156. // 总条数
  157. total: 0,
  158. // 专家信息表格数据
  159. expertsList: [],
  160. // 弹出层标题
  161. title: "",
  162. // 是否显示弹出层
  163. open: false,
  164. // 咨询对话框可见性
  165. consultationDialogVisible: false,
  166. // 选中的专家ID
  167. selectedExpertId: null,
  168. // 选中的专家姓名
  169. selectedExpertName: '',
  170. // 查询参数
  171. queryParams: {
  172. pageNum: 1,
  173. pageSize: 10,
  174. userId: null,
  175. realName: null,
  176. expertiseArea: null,
  177. contactInfo: null,
  178. isOnline: null,
  179. sortOrder: null,
  180. status: null,
  181. createdAt: null,
  182. updatedAt: null
  183. },
  184. // 表单参数
  185. form: {},
  186. // 表单校验
  187. rules: {
  188. userId: [
  189. { required: true, message: "关联用户ID不能为空", trigger: "blur" }
  190. ],
  191. }
  192. }
  193. },
  194. created() {
  195. this.getList()
  196. },
  197. methods: {
  198. /** 查询专家信息列表 */
  199. getList() {
  200. this.loading = true
  201. listExperts(this.queryParams).then(response => {
  202. this.expertsList = response.rows.map(item => {
  203. // 使用字典转换在线状态
  204. const onlineStatus = this.dict.type.is_online.find(dict => dict.value === item.isOnline)
  205. return {
  206. ...item,
  207. isOnlineText: onlineStatus ? onlineStatus.label : item.isOnline
  208. }
  209. })
  210. this.total = response.total
  211. this.loading = false
  212. })
  213. },
  214. // 取消按钮
  215. cancel() {
  216. this.open = false
  217. this.reset()
  218. },
  219. // 表单重置
  220. reset() {
  221. this.form = {
  222. expertId: null,
  223. userId: null,
  224. realName: null,
  225. expertiseArea: null,
  226. contactInfo: null,
  227. isOnline: null,
  228. sortOrder: null,
  229. status: null,
  230. createdAt: null,
  231. updatedAt: null
  232. }
  233. this.resetForm("form")
  234. },
  235. /** 搜索按钮操作 */
  236. handleQuery() {
  237. this.queryParams.pageNum = 1
  238. this.getList()
  239. },
  240. /** 重置按钮操作 */
  241. resetQuery() {
  242. this.resetForm("queryForm")
  243. this.handleQuery()
  244. },
  245. // 多选框选中数据
  246. handleSelectionChange(selection) {
  247. this.ids = selection.map(item => item.expertId)
  248. this.single = selection.length!==1
  249. this.multiple = !selection.length
  250. },
  251. /** 新增按钮操作 */
  252. handleAdd() {
  253. this.reset()
  254. this.open = true
  255. this.title = "添加专家信息"
  256. },
  257. /** 修改按钮操作 */
  258. handleUpdate(row) {
  259. this.reset()
  260. const expertId = row.expertId || this.ids
  261. getExperts(expertId).then(response => {
  262. this.form = response.data
  263. this.open = true
  264. this.title = "修改专家信息"
  265. })
  266. },
  267. /** 咨询按钮操作 */
  268. handleConsultation(row) {
  269. this.selectedExpertId = row.expertId
  270. this.selectedExpertName = row.realName
  271. this.consultationDialogVisible = true
  272. },
  273. /** 提交按钮 */
  274. submitForm() {
  275. this.$refs["form"].validate(valid => {
  276. if (valid) {
  277. if (this.form.expertId != null) {
  278. updateExperts(this.form).then(response => {
  279. this.$modal.msgSuccess("修改成功")
  280. this.open = false
  281. this.getList()
  282. })
  283. } else {
  284. addExperts(this.form).then(response => {
  285. this.$modal.msgSuccess("新增成功")
  286. this.open = false
  287. this.getList()
  288. })
  289. }
  290. }
  291. })
  292. },
  293. /** 删除按钮操作 */
  294. handleDelete(row) {
  295. const expertIds = row.expertId || this.ids
  296. this.$modal.confirm('是否确认删除专家信息编号为"' + expertIds + '"的数据项?').then(function() {
  297. return delExperts(expertIds)
  298. }).then(() => {
  299. this.getList()
  300. this.$modal.msgSuccess("删除成功")
  301. }).catch(() => {})
  302. },
  303. /** 导出按钮操作 */
  304. handleExport() {
  305. this.download('vet/experts/export', {
  306. ...this.queryParams
  307. }, `experts_${new Date().getTime()}.xlsx`)
  308. }
  309. }
  310. }
  311. </script>