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.

339 lines
11 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 label="兽医ID" prop="vetId">
  5. <el-input
  6. v-model="queryParams.vetId"
  7. placeholder="请输入兽医ID"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="是否在线" prop="isOnline">
  13. <el-input
  14. v-model="queryParams.isOnline"
  15. placeholder="请输入是否在线"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="最后在线时间" prop="lastOnlineTime">
  21. <el-date-picker clearable
  22. v-model="queryParams.lastOnlineTime"
  23. type="date"
  24. value-format="yyyy-MM-dd"
  25. placeholder="请选择最后在线时间">
  26. </el-date-picker>
  27. </el-form-item>
  28. <el-form-item label="最后活动时间" prop="lastActiveTime">
  29. <el-date-picker clearable
  30. v-model="queryParams.lastActiveTime"
  31. type="date"
  32. value-format="yyyy-MM-dd"
  33. placeholder="请选择最后活动时间">
  34. </el-date-picker>
  35. </el-form-item>
  36. <el-form-item label="当前咨询会话ID" prop="currentSessionId">
  37. <el-input
  38. v-model="queryParams.currentSessionId"
  39. placeholder="请输入当前咨询会话ID"
  40. clearable
  41. @keyup.enter.native="handleQuery"
  42. />
  43. </el-form-item>
  44. <el-form-item label="IP地址" prop="ipAddress">
  45. <el-input
  46. v-model="queryParams.ipAddress"
  47. placeholder="请输入IP地址"
  48. clearable
  49. @keyup.enter.native="handleQuery"
  50. />
  51. </el-form-item>
  52. <el-form-item>
  53. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  54. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  55. </el-form-item>
  56. </el-form>
  57. <el-row :gutter="10" class="mb8">
  58. <el-col :span="1.5">
  59. <el-button
  60. type="primary"
  61. plain
  62. icon="el-icon-plus"
  63. size="mini"
  64. @click="handleAdd"
  65. v-hasPermi="['system:status:add']"
  66. >新增</el-button>
  67. </el-col>
  68. <el-col :span="1.5">
  69. <el-button
  70. type="success"
  71. plain
  72. icon="el-icon-edit"
  73. size="mini"
  74. :disabled="single"
  75. @click="handleUpdate"
  76. v-hasPermi="['system:status:edit']"
  77. >修改</el-button>
  78. </el-col>
  79. <el-col :span="1.5">
  80. <el-button
  81. type="danger"
  82. plain
  83. icon="el-icon-delete"
  84. size="mini"
  85. :disabled="multiple"
  86. @click="handleDelete"
  87. v-hasPermi="['system:status:remove']"
  88. >删除</el-button>
  89. </el-col>
  90. <el-col :span="1.5">
  91. <el-button
  92. type="warning"
  93. plain
  94. icon="el-icon-download"
  95. size="mini"
  96. @click="handleExport"
  97. v-hasPermi="['system:status:export']"
  98. >导出</el-button>
  99. </el-col>
  100. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  101. </el-row>
  102. <el-table v-loading="loading" :data="statusList" @selection-change="handleSelectionChange">
  103. <el-table-column type="selection" width="55" align="center" />
  104. <el-table-column label="状态ID" align="center" prop="statusId" />
  105. <el-table-column label="兽医ID" align="center" prop="vetId" />
  106. <el-table-column label="是否在线" align="center" prop="isOnline" />
  107. <el-table-column label="在线状态" align="center" prop="onlineStatus" />
  108. <el-table-column label="最后在线时间" align="center" prop="lastOnlineTime" width="180">
  109. <template slot-scope="scope">
  110. <span>{{ parseTime(scope.row.lastOnlineTime, '{y}-{m}-{d}') }}</span>
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="最后活动时间" align="center" prop="lastActiveTime" width="180">
  114. <template slot-scope="scope">
  115. <span>{{ parseTime(scope.row.lastActiveTime, '{y}-{m}-{d}') }}</span>
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="当前咨询会话ID" align="center" prop="currentSessionId" />
  119. <el-table-column label="IP地址" align="center" prop="ipAddress" />
  120. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  121. <template slot-scope="scope">
  122. <el-button
  123. size="mini"
  124. type="text"
  125. icon="el-icon-edit"
  126. @click="handleUpdate(scope.row)"
  127. v-hasPermi="['system:status:edit']"
  128. >修改</el-button>
  129. <el-button
  130. size="mini"
  131. type="text"
  132. icon="el-icon-delete"
  133. @click="handleDelete(scope.row)"
  134. v-hasPermi="['system:status:remove']"
  135. >删除</el-button>
  136. </template>
  137. </el-table-column>
  138. </el-table>
  139. <pagination
  140. v-show="total>0"
  141. :total="total"
  142. :page.sync="queryParams.pageNum"
  143. :limit.sync="queryParams.pageSize"
  144. @pagination="getList"
  145. />
  146. <!-- 添加或修改专家在线状态对话框 -->
  147. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  148. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  149. <el-form-item label="兽医ID" prop="vetId">
  150. <el-input v-model="form.vetId" placeholder="请输入兽医ID" />
  151. </el-form-item>
  152. <el-form-item label="是否在线" prop="isOnline">
  153. <el-input v-model="form.isOnline" placeholder="请输入是否在线" />
  154. </el-form-item>
  155. <el-form-item label="最后在线时间" prop="lastOnlineTime">
  156. <el-date-picker clearable
  157. v-model="form.lastOnlineTime"
  158. type="date"
  159. value-format="yyyy-MM-dd"
  160. placeholder="请选择最后在线时间">
  161. </el-date-picker>
  162. </el-form-item>
  163. <el-form-item label="最后活动时间" prop="lastActiveTime">
  164. <el-date-picker clearable
  165. v-model="form.lastActiveTime"
  166. type="date"
  167. value-format="yyyy-MM-dd"
  168. placeholder="请选择最后活动时间">
  169. </el-date-picker>
  170. </el-form-item>
  171. <el-form-item label="当前咨询会话ID" prop="currentSessionId">
  172. <el-input v-model="form.currentSessionId" placeholder="请输入当前咨询会话ID" />
  173. </el-form-item>
  174. <el-form-item label="IP地址" prop="ipAddress">
  175. <el-input v-model="form.ipAddress" placeholder="请输入IP地址" />
  176. </el-form-item>
  177. </el-form>
  178. <div slot="footer" class="dialog-footer">
  179. <el-button type="primary" @click="submitForm"> </el-button>
  180. <el-button @click="cancel"> </el-button>
  181. </div>
  182. </el-dialog>
  183. </div>
  184. </template>
  185. <script>
  186. import { listStatus, getStatus, delStatus, addStatus, updateStatus } from "@/api/system/status"
  187. export default {
  188. name: "Status",
  189. data() {
  190. return {
  191. // 遮罩层
  192. loading: true,
  193. // 选中数组
  194. ids: [],
  195. // 非单个禁用
  196. single: true,
  197. // 非多个禁用
  198. multiple: true,
  199. // 显示搜索条件
  200. showSearch: true,
  201. // 总条数
  202. total: 0,
  203. // 专家在线状态表格数据
  204. statusList: [],
  205. // 弹出层标题
  206. title: "",
  207. // 是否显示弹出层
  208. open: false,
  209. // 查询参数
  210. queryParams: {
  211. pageNum: 1,
  212. pageSize: 10,
  213. vetId: null,
  214. isOnline: null,
  215. onlineStatus: null,
  216. lastOnlineTime: null,
  217. lastActiveTime: null,
  218. currentSessionId: null,
  219. ipAddress: null
  220. },
  221. // 表单参数
  222. form: {},
  223. // 表单校验
  224. rules: {
  225. vetId: [
  226. { required: true, message: "兽医ID不能为空", trigger: "blur" }
  227. ],
  228. }
  229. }
  230. },
  231. created() {
  232. this.getList()
  233. },
  234. methods: {
  235. /** 查询专家在线状态列表 */
  236. getList() {
  237. this.loading = true
  238. listStatus(this.queryParams).then(response => {
  239. this.statusList = response.rows
  240. this.total = response.total
  241. this.loading = false
  242. })
  243. },
  244. // 取消按钮
  245. cancel() {
  246. this.open = false
  247. this.reset()
  248. },
  249. // 表单重置
  250. reset() {
  251. this.form = {
  252. statusId: null,
  253. vetId: null,
  254. isOnline: null,
  255. onlineStatus: null,
  256. lastOnlineTime: null,
  257. lastActiveTime: null,
  258. currentSessionId: null,
  259. ipAddress: null
  260. }
  261. this.resetForm("form")
  262. },
  263. /** 搜索按钮操作 */
  264. handleQuery() {
  265. this.queryParams.pageNum = 1
  266. this.getList()
  267. },
  268. /** 重置按钮操作 */
  269. resetQuery() {
  270. this.resetForm("queryForm")
  271. this.handleQuery()
  272. },
  273. // 多选框选中数据
  274. handleSelectionChange(selection) {
  275. this.ids = selection.map(item => item.statusId)
  276. this.single = selection.length!==1
  277. this.multiple = !selection.length
  278. },
  279. /** 新增按钮操作 */
  280. handleAdd() {
  281. this.reset()
  282. this.open = true
  283. this.title = "添加专家在线状态"
  284. },
  285. /** 修改按钮操作 */
  286. handleUpdate(row) {
  287. this.reset()
  288. const statusId = row.statusId || this.ids
  289. getStatus(statusId).then(response => {
  290. this.form = response.data
  291. this.open = true
  292. this.title = "修改专家在线状态"
  293. })
  294. },
  295. /** 提交按钮 */
  296. submitForm() {
  297. this.$refs["form"].validate(valid => {
  298. if (valid) {
  299. if (this.form.statusId != null) {
  300. updateStatus(this.form).then(response => {
  301. this.$modal.msgSuccess("修改成功")
  302. this.open = false
  303. this.getList()
  304. })
  305. } else {
  306. addStatus(this.form).then(response => {
  307. this.$modal.msgSuccess("新增成功")
  308. this.open = false
  309. this.getList()
  310. })
  311. }
  312. }
  313. })
  314. },
  315. /** 删除按钮操作 */
  316. handleDelete(row) {
  317. const statusIds = row.statusId || this.ids
  318. this.$modal.confirm('是否确认删除专家在线状态编号为"' + statusIds + '"的数据项?').then(function() {
  319. return delStatus(statusIds)
  320. }).then(() => {
  321. this.getList()
  322. this.$modal.msgSuccess("删除成功")
  323. }).catch(() => {})
  324. },
  325. /** 导出按钮操作 */
  326. handleExport() {
  327. this.download('system/status/export', {
  328. ...this.queryParams
  329. }, `status_${new Date().getTime()}.xlsx`)
  330. }
  331. }
  332. }
  333. </script>