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.

310 lines
9.1 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-item>-->
  5. <!-- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>-->
  6. <!-- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>-->
  7. <!-- </el-form-item>-->
  8. <!-- </el-form>-->
  9. <el-row :gutter="10" class="mb8">
  10. <el-col :span="1.5">
  11. <el-button
  12. type="primary"
  13. plain
  14. icon="el-icon-plus"
  15. size="mini"
  16. @click="handleAdd"
  17. v-hasPermi="['vet:comments:add']"
  18. >新增</el-button>
  19. </el-col>
  20. <!-- <el-col :span="1.5">-->
  21. <!-- <el-button-->
  22. <!-- type="success"-->
  23. <!-- plain-->
  24. <!-- icon="el-icon-edit"-->
  25. <!-- size="mini"-->
  26. <!-- :disabled="single"-->
  27. <!-- @click="handleUpdate"-->
  28. <!-- v-hasPermi="['vet:comments:edit']"-->
  29. <!-- >修改</el-button>-->
  30. <!-- </el-col>-->
  31. <!-- <el-col :span="1.5">-->
  32. <!-- <el-button-->
  33. <!-- type="danger"-->
  34. <!-- plain-->
  35. <!-- icon="el-icon-delete"-->
  36. <!-- size="mini"-->
  37. <!-- :disabled="multiple"-->
  38. <!-- @click="handleDelete"-->
  39. <!-- v-hasPermi="['vet:comments:remove']"-->
  40. <!-- >删除</el-button>-->
  41. <!-- </el-col>-->
  42. <!-- <el-col :span="1.5">-->
  43. <!-- <el-button-->
  44. <!-- type="warning"-->
  45. <!-- plain-->
  46. <!-- icon="el-icon-download"-->
  47. <!-- size="mini"-->
  48. <!-- @click="handleExport"-->
  49. <!-- v-hasPermi="['vet:comments:export']"-->
  50. <!-- >导出</el-button>-->
  51. <!-- </el-col>-->
  52. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  53. </el-row>
  54. <el-table v-loading="loading" :data="commentsList" @selection-change="handleSelectionChange">
  55. <el-table-column type="selection" width="55" align="center" />
  56. <el-table-column label="头像" align="center" prop="avatar" width="100">
  57. <template slot-scope="scope">
  58. <image-preview :src="scope.row.avatar" :width="50" :height="50" />
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="回复者" align="center" prop="replyName" />
  62. <el-table-column label="职称" align="center" prop="title" />
  63. <el-table-column label="从属医院" align="center" prop="hospital" />
  64. <el-table-column label="从业经验" align="center" prop="experience" />
  65. <el-table-column label="回复内容" align="center" prop="content" />
  66. <el-table-column label="回复图片" align="center" prop="images" width="100">
  67. <template slot-scope="scope">
  68. <image-preview :src="scope.row.images" :width="50" :height="50" />
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="回复时间" align="center" prop="updatedAt" width="180">
  72. <template slot-scope="scope">
  73. <span>{{ parseTime(scope.row.createdAt, '{y}-{m}-{d}') }}</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  77. <template slot-scope="scope">
  78. <el-button
  79. size="mini"
  80. type="text"
  81. icon="el-icon-edit"
  82. @click="handleUpdate(scope.row)"
  83. v-hasPermi="['vet:comments:edit']"
  84. >修改</el-button>
  85. <el-button
  86. size="mini"
  87. type="text"
  88. icon="el-icon-delete"
  89. @click="handleDelete(scope.row)"
  90. v-hasPermi="['vet:comments:remove']"
  91. >删除</el-button>
  92. </template>
  93. </el-table-column>
  94. </el-table>
  95. <pagination
  96. v-show="total>0"
  97. :total="total"
  98. :page.sync="queryParams.pageNum"
  99. :limit.sync="queryParams.pageSize"
  100. @pagination="getList"
  101. />
  102. <!-- 添加或修改兽医回复对话框 -->
  103. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  104. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  105. <el-form-item label="回复内容" prop="content">
  106. <el-input v-model="form.content" placeholder="请输入回复内容" />
  107. </el-form-item>
  108. <el-form-item label="回复图片" prop="images">
  109. <image-upload v-model="form.images" />
  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. </div>
  118. </template>
  119. <script>
  120. import { listComments, getComments, delComments, addComments, updateComments } from "@/api/vet/comments"
  121. export default {
  122. name: "Comments",
  123. props: {
  124. // 接收问诊单ID
  125. consultationId: {
  126. type: Number,
  127. required: true
  128. }
  129. },
  130. data() {
  131. return {
  132. // 遮罩层
  133. loading: true,
  134. // 选中数组
  135. ids: [],
  136. // 非单个禁用
  137. single: true,
  138. // 非多个禁用
  139. multiple: true,
  140. // 显示搜索条件
  141. showSearch: true,
  142. // 总条数
  143. total: 0,
  144. // 兽医回复表格数据
  145. commentsList: [],
  146. // 弹出层标题
  147. title: "",
  148. // 是否显示弹出层
  149. open: false,
  150. // 查询参数
  151. queryParams: {
  152. pageNum: 1,
  153. pageSize: 10,
  154. consultationId: null,
  155. replyName: null,
  156. content: null,
  157. images: null,
  158. isSensitive: null,
  159. sensitiveWords: null,
  160. createdAt: null,
  161. updatedAt: null,
  162. userId: null
  163. },
  164. // 表单参数
  165. form: {
  166. consultationId: null
  167. },
  168. // 表单校验
  169. rules: {
  170. }
  171. }
  172. },
  173. created() {
  174. this.queryParams.consultationId = this.parseConsultationId(this.consultationId)
  175. this.getList()
  176. },
  177. methods: {
  178. /** 查询兽医回复列表 */
  179. getList() {
  180. this.loading = true
  181. listComments(this.queryParams).then(response => {
  182. this.commentsList = response.rows
  183. this.total = response.total
  184. this.loading = false
  185. })
  186. },
  187. // 取消按钮
  188. cancel() {
  189. this.open = false
  190. this.reset()
  191. },
  192. // 表单重置
  193. reset() {
  194. this.form = {
  195. id: null,
  196. consultationId: this.consultationId,
  197. replyName: null,
  198. content: null,
  199. images: null,
  200. isSensitive: null,
  201. sensitiveWords: null,
  202. createdAt: null,
  203. updatedAt: null,
  204. userId: null
  205. }
  206. this.resetForm("form")
  207. },
  208. /** 搜索按钮操作 */
  209. handleQuery() {
  210. this.queryParams.pageNum = 1
  211. this.getList()
  212. },
  213. /** 重置按钮操作 */
  214. resetQuery() {
  215. this.resetForm("queryForm")
  216. this.handleQuery()
  217. },
  218. // 多选框选中数据
  219. handleSelectionChange(selection) {
  220. this.ids = selection.map(item => item.id)
  221. this.single = selection.length!==1
  222. this.multiple = !selection.length
  223. },
  224. /** 新增按钮操作 */
  225. handleAdd() {
  226. this.reset()
  227. this.open = true
  228. this.title = "添加兽医回复"
  229. this.form.consultationId = this.consultationId;
  230. },
  231. /** 修改按钮操作 */
  232. handleUpdate(row) {
  233. this.reset()
  234. const id = row.id || this.ids
  235. getComments(id).then(response => {
  236. this.form = response.data
  237. this.open = true
  238. this.title = "修改兽医回复"
  239. })
  240. },
  241. /** 提交按钮 */
  242. submitForm() {
  243. this.$refs["form"].validate(valid => {
  244. if (valid) {
  245. if (this.form.id != null) {
  246. updateComments(this.form).then(response => {
  247. this.$modal.msgSuccess("修改成功")
  248. this.open = false
  249. this.getList()
  250. })
  251. } else {
  252. addComments(this.form).then(response => {
  253. this.$modal.msgSuccess("新增成功")
  254. this.open = false
  255. this.getList()
  256. })
  257. }
  258. }
  259. })
  260. },
  261. /** 删除按钮操作 */
  262. handleDelete(row) {
  263. const ids = row.id || this.ids
  264. this.$modal.confirm('是否确认删除兽医回复编号为"' + ids + '"的数据项?').then(function() {
  265. return delComments(ids)
  266. }).then(() => {
  267. this.getList()
  268. this.$modal.msgSuccess("删除成功")
  269. }).catch(() => {})
  270. },
  271. /** 导出按钮操作 */
  272. handleExport() {
  273. this.download('vet/comments/export', {
  274. ...this.queryParams
  275. }, `comments_${new Date().getTime()}.xlsx`)
  276. },
  277. parseConsultationId(id) {
  278. if (id == null || id === '' || id === undefined) {
  279. return null
  280. }
  281. // 处理字符串"NaN"
  282. if (id === 'NaN' || id === 'nan' || id === 'Nan') {
  283. console.warn('检测到无效的consultationId: NaN')
  284. return null
  285. }
  286. // 尝试转换为数字
  287. const num = Number(id)
  288. // 检查是否为有效数字且是整数
  289. if (!isNaN(num) && Number.isInteger(num) && num > 0) {
  290. return num
  291. }
  292. console.error('无效的consultationId:', id)
  293. return null
  294. }
  295. }
  296. }
  297. </script>