TableBox.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <div>
  3. <div class="btn-box">
  4. <el-select v-model="ruleType" placeholder="请选择规则类型" style="width: 150px; margin-right: 10px;">
  5. <el-option label="病历规则" :value="1" />
  6. <el-option label="首页规则" :value="2" />
  7. </el-select>
  8. <el-button type="primary" icon="el-icon-plus" style="margin-right: 10px;" @click="onCreate">新增</el-button>
  9. <el-popover
  10. placement="bottom-end"
  11. title=""
  12. trigger="click"
  13. popper-class="table_code_popper"
  14. >
  15. <el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">全选</el-checkbox>
  16. <el-checkbox-group v-model="codes" @change="handleChange">
  17. <el-checkbox label="description">规则描述</el-checkbox>
  18. <el-checkbox label="department">质控科室</el-checkbox>
  19. <el-checkbox label="is_not">单项否决</el-checkbox>
  20. <el-checkbox label="status">质控状态</el-checkbox>
  21. <el-checkbox label="type">质控类型</el-checkbox>
  22. <el-checkbox label="changjing">质控场景</el-checkbox>
  23. <el-checkbox label="error_level">风险等级</el-checkbox>
  24. <el-checkbox label="score">扣分</el-checkbox>
  25. <el-checkbox label="rule">质控规则</el-checkbox>
  26. </el-checkbox-group>
  27. <el-button slot="reference" type="primary" icon="el-icon-setting">设置</el-button>
  28. </el-popover>
  29. </div>
  30. <el-table
  31. v-loading="loading"
  32. :data="data"
  33. border
  34. :max-height="630"
  35. style="width: 100%"
  36. >
  37. <el-table-column
  38. type="index"
  39. label="序号"
  40. width="80"
  41. fixed="left"
  42. align="center"
  43. />
  44. <el-table-column
  45. prop="case_type"
  46. :label="ruleType === 1 ? '病历类型' : '首页字段'"
  47. fixed="left"
  48. align="center"
  49. width="120"
  50. />
  51. <el-table-column
  52. prop="object"
  53. :label="ruleType === 1 ? '质控项目' : '缺陷类别'"
  54. align="center"
  55. width="240"
  56. />
  57. <el-table-column
  58. v-if="codes.includes('description')"
  59. prop="description"
  60. label="规则描述"
  61. min-width="240"
  62. align="center"
  63. />
  64. <el-table-column
  65. v-if="codes.includes('department')"
  66. prop="department"
  67. :label="ruleType === 1 ? '质控科室' : '缺陷类型'"
  68. min-width="120"
  69. align="center"
  70. >
  71. <template slot-scope="scope">
  72. {{ formatDepartment(scope.row.department) }}
  73. </template>
  74. </el-table-column>
  75. <el-table-column
  76. v-if="codes.includes('is_not')"
  77. prop="is_not"
  78. label="单项否决"
  79. align="center"
  80. width="120"
  81. >
  82. <template slot-scope="scope">
  83. <el-tag v-if="scope.row.is_not" type="primary">是</el-tag>
  84. <el-tag v-else type="info">否</el-tag>
  85. </template>
  86. </el-table-column>
  87. <el-table-column
  88. v-if="codes.includes('status')"
  89. prop="status"
  90. label="质控状态"
  91. align="center"
  92. width="120"
  93. >
  94. <template slot-scope="scope">
  95. <el-switch
  96. v-model="scope.row.status"
  97. active-color="#13ce66"
  98. :active-value="1"
  99. :inactive-value="2"
  100. @change="handleStatusChange(scope.row)"
  101. />
  102. </template>
  103. <!-- <template slot-scope="scope">
  104. <el-tag v-if="scope.row.status === 1" type="success">开启中</el-tag>
  105. <el-tag v-if="scope.row.status === 2" type="danger">禁用中</el-tag>
  106. </template> -->
  107. </el-table-column>
  108. <el-table-column
  109. v-if="codes.includes('type')"
  110. prop="type"
  111. label="质控类型"
  112. align="center"
  113. width="120"
  114. />
  115. <el-table-column
  116. v-if="codes.includes('changjing')"
  117. prop="changjing"
  118. label="质控场景"
  119. align="center"
  120. width="120"
  121. />
  122. <el-table-column
  123. v-if="codes.includes('error_level')"
  124. prop="error_level"
  125. label="风险等级"
  126. align="center"
  127. width="120"
  128. >
  129. <template slot-scope="scope">
  130. <el-tag v-if="scope.row.error_level === 1" type="danger">必改</el-tag>
  131. <el-tag v-if="scope.row.error_level === 2" type="primary">建议</el-tag>
  132. <!-- <el-tag v-if="scope.row.error_level === 3" type="danger">高风险</el-tag> -->
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. v-if="codes.includes('score')"
  137. prop="score"
  138. label="扣分"
  139. align="center"
  140. width="120"
  141. />
  142. <el-table-column
  143. v-if="codes.includes('rule')"
  144. prop=""
  145. label="质控规则"
  146. align="center"
  147. width="120"
  148. >
  149. <template slot-scope="scope">
  150. <el-button type="primary" size="mini" @click="onRuleDetail(scope.row)">查看详情</el-button>
  151. </template>
  152. </el-table-column>
  153. <el-table-column
  154. prop=""
  155. label="操作"
  156. align="center"
  157. fixed="right"
  158. width="140"
  159. >
  160. <template slot-scope="scope">
  161. <el-button type="text" @click="onEdit(scope.row)">修改</el-button>
  162. <el-button type="text" style="color: #F56C6C;" @click="onDel(scope.row)">删除</el-button>
  163. <el-button type="text" @click="onTest">测试</el-button>
  164. </template>
  165. </el-table-column>
  166. </el-table>
  167. <!-- 新增、编辑 病历规则 -->
  168. <CreateDialog v-if="createData.bSwitch" :data="createData" :departments="departments" :objects="objects" @refresh="handleRefresh" />
  169. <!-- 新增、编辑 首页规则 -->
  170. <HomePageRuleDialog v-if="homePageRuleData.bSwitch" :data="homePageRuleData" :departments="departments" :objects="objects" @refresh="handleRefresh" />
  171. <!-- 规则详情 -->
  172. <RuleDialog v-if="ruleData.bSwitch" :data="ruleData" :departments="departments" :objects="objects" />
  173. </div>
  174. </template>
  175. <script>
  176. import CreateDialog from './CreateDialog.vue'
  177. import RuleDialog from './RuleDialog.vue'
  178. import HomePageRuleDialog from './HomePageRuleDialog.vue'
  179. import { del_rule, edit_rule_status } from '@/api/rule/config'
  180. export default {
  181. components: {
  182. CreateDialog,
  183. RuleDialog,
  184. HomePageRuleDialog
  185. },
  186. props: {
  187. data: {
  188. type: Array,
  189. default() {
  190. return []
  191. }
  192. },
  193. loading: {
  194. type: Boolean,
  195. default() {
  196. return false
  197. }
  198. },
  199. objects: {
  200. type: Array,
  201. default() {
  202. return []
  203. }
  204. },
  205. departments: {
  206. type: Array,
  207. default() {
  208. return []
  209. }
  210. }
  211. },
  212. data() {
  213. return {
  214. ruleType: 1,
  215. codes: [
  216. 'changjing',
  217. 'department',
  218. 'type',
  219. 'is_not',
  220. 'score',
  221. 'error_level',
  222. 'status',
  223. 'description',
  224. 'rule'
  225. ],
  226. defaultCodes: [],
  227. checkAll: true,
  228. isIndeterminate: false,
  229. createData: {
  230. bSwitch: false,
  231. row: {}
  232. },
  233. homePageRuleData: {
  234. bSwitch: false,
  235. row: {}
  236. },
  237. ruleData: {
  238. bSwitch: false,
  239. row: {}
  240. },
  241. statusArr: [
  242. { 'id': 1, 'name': '启用' },
  243. { 'id': 2, 'name': '停用' }
  244. ]
  245. }
  246. },
  247. watch: {
  248. ruleType(newVal) {
  249. this.$emit('refresh', { rule_type: newVal })
  250. }
  251. },
  252. created() {
  253. this.defaultCodes = JSON.parse(JSON.stringify(this.codes))
  254. },
  255. methods: {
  256. onTest() {
  257. this.$message.info('功能待开放...')
  258. },
  259. onCreate() {
  260. if (this.ruleType === 1) {
  261. // 病历规则
  262. this.createData.row = { rule_type: this.ruleType }
  263. this.createData.bSwitch = true
  264. } else if (this.ruleType === 2) {
  265. // 首页规则
  266. this.homePageRuleData.row = { rule_type: this.ruleType }
  267. this.homePageRuleData.bSwitch = true
  268. }
  269. },
  270. onEdit(row) {
  271. if (this.ruleType === 1) {
  272. // 病历规则
  273. this.createData.row = row
  274. this.createData.bSwitch = true
  275. } else if (this.ruleType === 2) {
  276. // 首页规则
  277. this.homePageRuleData.row = row
  278. this.homePageRuleData.bSwitch = true
  279. }
  280. },
  281. handleRefresh() {
  282. this.$emit('refresh', { rule_type: this.ruleType })
  283. },
  284. // 删除规则
  285. onDel(row) {
  286. this.$confirm('是否确认删除该数据?', '提示', {
  287. confirmButtonText: '确定',
  288. cancelButtonText: '取消',
  289. type: 'warning'
  290. }).then(() => {
  291. del_rule({ id: row.id }).then((res) => {
  292. this.$message.success(res.m || '操作成功')
  293. this.$emit('refresh')
  294. })
  295. })
  296. },
  297. // 查看规则
  298. onRuleDetail(row) {
  299. this.ruleData.row = row
  300. this.ruleData.bSwitch = true
  301. },
  302. handleCheckAllChange(val) {
  303. this.codes = val ? this.defaultCodes : []
  304. this.isIndeterminate = false
  305. },
  306. // 展示字段发生变化
  307. handleChange(val) {
  308. const checkedCount = val.length
  309. this.checkAll = checkedCount === this.defaultCodes.length
  310. },
  311. handleStatusChange(row) {
  312. const statusIndex = this.statusArr.findIndex((value) => parseInt(value.id) === parseInt(row.status))
  313. this.$confirm('确认要更改为 <strong>' + this.statusArr[statusIndex].name + '</strong> 状态吗?', '提示', {
  314. dangerouslyUseHTMLString: true,
  315. confirmButtonText: '确定',
  316. cancelButtonText: '取消',
  317. type: 'warning'
  318. }).then(() => {
  319. edit_rule_status({ id: row.id, status: row.status }).then((res) => {
  320. this.$message.success(res.m || '操作成功')
  321. }).catch(function() {
  322. row.status = row.status === 1 ? 2 : 1
  323. })
  324. }).catch(function() {
  325. row.status = row.status === 1 ? 2 : 1
  326. })
  327. },
  328. formatDepartment(department) {
  329. if (!department || (Array.isArray(department) && department.length === 0)) {
  330. return '通用'
  331. }
  332. // 如果需要显示科室名称而不是编码,可以通过 departments 数据查找对应的名称
  333. return Array.isArray(department) ? department.join('、') : department
  334. }
  335. }
  336. }
  337. </script>
  338. <style lang="scss" scoped>
  339. .btn-box {
  340. text-align: right;
  341. margin-bottom: 15px;
  342. }
  343. </style>
  344. <style lang="scss">
  345. .table_code_popper {
  346. .el-checkbox {
  347. display: block;
  348. line-height: 26px;
  349. }
  350. }
  351. </style>