index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <!--检查项管理-->
  2. <template>
  3. <div class="app-container checkOption">
  4. <div class="checkOptionPage" v-if="pageType == 1">
  5. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  6. <el-form-item style="float: right;">
  7. <el-col :span="1.5">
  8. <el-button
  9. style="width:140px;"
  10. type="primary"
  11. plain
  12. @click="addDialog(1)"
  13. v-hasPermi="['laboratory:checkOption:add']"
  14. ><i class="el-icon-plus" style="margin-right:10px;"></i>添加检查项</el-button>
  15. </el-col>
  16. <el-col :span="1.5">
  17. <el-button
  18. style="width:100px;margin:0 10px;"
  19. type="primary"
  20. plain
  21. @click="importClick"
  22. v-hasPermi="['laboratory:checkOption:import']"
  23. >批量导入</el-button>
  24. </el-col>
  25. <el-col :span="1.5">
  26. <el-button
  27. style="width:100px;"
  28. type="primary"
  29. plain
  30. @click="handleExport"
  31. v-hasPermi="['laboratory:checkOption:export']"
  32. >下载模板</el-button>
  33. </el-col>
  34. <el-col :span="1.5">
  35. <el-button
  36. style="width:140px;margin:0 0 0 10px;"
  37. type="primary"
  38. plain
  39. @click="goPageType(2)"
  40. v-hasPermi="['laboratory:checkOption:list']"
  41. >检查项提交记录</el-button>
  42. </el-col>
  43. </el-form-item>
  44. </el-form>
  45. <el-table border
  46. v-loading="loading"
  47. :data="checkOptionList"
  48. row-key="id"
  49. default-expand-all
  50. :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
  51. >
  52. <el-table-column prop="name" label="检查项名称">
  53. <template slot-scope="scope">
  54. <el-tooltip :disabled="scope.row.name.length < 74" class="item" effect="dark" :content="scope.row.name" placement="top-start">
  55. <div style="display:inline-block;margin:0;">
  56. <p style="max-width:1100px;overflow: hidden;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0;">
  57. <span>{{scope.row.code}}</span><span>{{scope.row.name}}</span>
  58. </p>
  59. </div>
  60. </el-tooltip>
  61. </template>
  62. <!--<template slot-scope="scope" :show-overflow-tooltip="true">{{scope.row.code}}{{scope.row.name}}-->
  63. <!--<div style="display: inline-block;">-->
  64. <!--<div style="display: flex;">-->
  65. <!--<p style="margin:0 10px 0 0;height:17px;">{{scope.row.code}}</p>-->
  66. <!--<p style="margin:0;height:17px;">{{scope.row.name}}</p>-->
  67. <!--</div>-->
  68. <!--</div>-->
  69. <!--<span style="margin-right:10px;">{{scope.row.code}}</span><span>{{scope.row.name}}</span>-->
  70. <!--</template>-->
  71. </el-table-column>
  72. <el-table-column label="操作" width="240" v-if="tableButtonType">
  73. <template slot-scope="scope">
  74. <div class="button-box" style="display: flex">
  75. <p
  76. v-if="scope.row.tabelLevel < 4"
  77. class="table-min-button"
  78. style="margin-right: 10px"
  79. v-hasPermi="['laboratory:checkOption:add']"
  80. @click="addDialog(2,scope.row)">新增
  81. </p>
  82. <p class="table-min-button"
  83. style="margin-right: 10px"
  84. v-hasPermiAnd="['laboratory:checkOption:add','laboratory:checkOption:edit']"
  85. @click="editDialog(scope.row)">编辑</p>
  86. <p class="table-min-button"
  87. v-hasPermi="['laboratory:checkOption:remove']"
  88. @click="handleDelete(scope.row)">删除</p>
  89. </div>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. </div>
  94. <check-config-list-page v-if="pageType == 2"></check-config-list-page>
  95. <!--新增/编辑-->
  96. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  97. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  98. <el-form-item label="检查项名称" prop="name">
  99. <el-input type="textarea" maxlength="30" v-model="form.name" placeholder="请输入检查项名称" rows="3" resize="none"></el-input>
  100. </el-form-item>
  101. <el-form-item label="条款号" prop="code">
  102. <el-input v-model="form.code" maxlength="7" placeholder="请输入条款号"/>
  103. </el-form-item>
  104. </el-form>
  105. <div slot="footer" class="dialog-footer">
  106. <el-button @click="cancel">取 消</el-button>
  107. <el-button type="primary" @click="submitForm">确 定</el-button>
  108. </div>
  109. </el-dialog>
  110. <!--导入-->
  111. <el-dialog title="批量导入" :visible.sync="importOpen" width="700px" append-to-body>
  112. <div style="width:660px;">
  113. <p style="margin:0 0 20px;font-size:20px;text-align: center;">请按格式上传检查项,确保上传的文件内容格式与模版一致</p>
  114. <p class="reset-button-one" style="display:block;width:400px;margin:0 auto 20px;height:50px;line-height:50px;color:#666;border:1px solid #666;" @click="handleExport">下载模板</p>
  115. <el-upload
  116. style="width:400px;margin:0 auto 20px;"
  117. class="avatar-uploader"
  118. :action="uploadImgUrl"
  119. :show-file-list="false"
  120. accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
  121. :on-success="handleAvatarSuccess"
  122. :headers="headers"
  123. :before-upload="beforeAvatarUpload">
  124. <p class="inquire-button-one" style="display:block;width:400px;margin:0 auto 20px;height:50px;line-height:50px;">选择文件</p>
  125. </el-upload>
  126. </div>
  127. </el-dialog>
  128. </div>
  129. </template>
  130. <script>
  131. import { listCheckOption, getCheckOption, delCheckOption, addCheckOption, updateCheckOption } from "@/api/laboratory/checkOption";
  132. import checkConfigListPage from "./checkConfigListPage.vue"
  133. import { getToken } from "@/utils/auth";
  134. export default {
  135. name: "CheckOption",
  136. components: {
  137. checkConfigListPage,
  138. },
  139. data() {
  140. return {
  141. tableButtonType:this.hasPermiDom(['laboratory:checkOption:add','laboratory:checkOption:add','laboratory:checkOption:edit','laboratory:checkOption:remove']),
  142. uploadImgUrl: window.location.href.split('://')[0]+'://' + this.judgmentNetworkReturnAddress() + "/laboratory/checkOption/import", // 上传的图片服务器地址
  143. headers: {
  144. Authorization: "Bearer " + getToken(),
  145. },
  146. //页面状态
  147. pageType:1,
  148. // 遮罩层
  149. loading: true,
  150. // 选中数组
  151. ids: [],
  152. // 非单个禁用
  153. single: true,
  154. // 非多个禁用
  155. multiple: true,
  156. // 显示搜索条件
  157. showSearch: true,
  158. // 总条数
  159. total: 0,
  160. // 检查项选项表格数据
  161. checkOptionList: [],
  162. // 弹出层标题
  163. title: "",
  164. // 是否显示弹出层
  165. open: false,
  166. // 查询参数
  167. queryParams: {
  168. pageNum: 1,
  169. pageSize:20,
  170. deptId: null,
  171. deptName: null,
  172. userId: null,
  173. name: null,
  174. parentId: null
  175. },
  176. // 表单参数
  177. form: {},
  178. // 表单校验
  179. rules: {
  180. name: [
  181. { required: true, message: "请输入检查项名称", trigger: "blur" },
  182. { required: true, message: "请输入检查项名称", validator: this.spaceJudgment, trigger: "blur" }
  183. ],
  184. code: [
  185. { required: true, message: "请输入条款号", trigger: "blur" },
  186. { required: true, message: "请输入条款号", validator: this.spaceJudgment, trigger: "blur" }
  187. ],
  188. },
  189. options:[],
  190. //导入
  191. importOpen:false,
  192. //新增/编辑状态
  193. dialogType:"",
  194. };
  195. },
  196. created() {
  197. },
  198. mounted(){
  199. this.getList();
  200. },
  201. methods: {
  202. //导入窗口
  203. importClick(){
  204. this.importOpen = true;
  205. },
  206. // 添加检查项
  207. addDialog(type,row){
  208. this.title = "添加检查项";
  209. if(type == 1){
  210. let obj = {
  211. parentId:0,
  212. name:"",
  213. level:1,
  214. }
  215. this.$set(this,'form',obj)
  216. }else if(type == 2){
  217. let obj = {
  218. parentId:row.id,
  219. name:"",
  220. level:row.tabelLevel+1,
  221. }
  222. this.$set(this,'form',obj)
  223. }
  224. this.dialogType = 1;
  225. this.open = true;
  226. this.$refs['form'].clearValidate();
  227. // this.$refs['form'].clearValidate('name');
  228. // this.$refs['form'].clearValidate('code');
  229. },
  230. // 编辑检查项
  231. editDialog(row){
  232. this.title = "编辑检查项";
  233. let obj = JSON.parse(JSON.stringify(row))
  234. this.$set(this,'form',obj)
  235. this.dialogType = 2;
  236. this.open = true;
  237. },
  238. goPageType(type){
  239. if(type == 2){
  240. this.pageType = 2;
  241. }else if(type == 1){
  242. this.pageType = 1;
  243. }
  244. },
  245. /** 查询检查项选项列表 */
  246. getList() {
  247. this.loading = true;
  248. listCheckOption(this.queryParams).then( response => {
  249. for(let a=0;a<response.data.length;a++){
  250. response.data[a].tabelLevel = 1
  251. for(let b=0;b<response.data[a].children.length;b++){
  252. response.data[a].children[b].tabelLevel = 2
  253. for(let c=0;c<response.data[a].children[b].children.length;c++){
  254. response.data[a].children[b].children[c].tabelLevel = 3
  255. for(let d=0;d<response.data[a].children[b].children[c].children.length;d++){
  256. response.data[a].children[b].children[c].children[d].tabelLevel = 4
  257. }
  258. }
  259. }
  260. }
  261. this.checkOptionList = response.data;
  262. this.total = response.total;
  263. this.loading = false;
  264. });
  265. },
  266. // 取消按钮
  267. cancel() {
  268. this.open = false;
  269. this.reset();
  270. },
  271. // 表单重置
  272. reset() {
  273. this.form = {
  274. id: null,
  275. deptId: null,
  276. deptName: null,
  277. userId: null,
  278. createBy: null,
  279. createTime: null,
  280. updateBy: null,
  281. updateTime: null,
  282. remark: null,
  283. name: null,
  284. parentId: null
  285. };
  286. this.resetForm("form");
  287. },
  288. /** 搜索按钮操作 */
  289. handleQuery() {
  290. this.queryParams.pageNum = 1;
  291. this.getList();
  292. },
  293. /** 重置按钮操作 */
  294. resetQuery() {
  295. this.resetForm("queryForm");
  296. this.handleQuery();
  297. },
  298. // 多选框选中数据
  299. handleSelectionChange(selection) {
  300. this.ids = selection.map(item => item.id)
  301. this.single = selection.length!==1
  302. this.multiple = !selection.length
  303. },
  304. /** 新增按钮操作 */
  305. handleAdd() {
  306. this.reset();
  307. this.open = true;
  308. this.title = "添加检查项选项";
  309. },
  310. /** 修改按钮操作 */
  311. handleUpdate(row) {
  312. this.reset();
  313. const id = row.id || this.ids
  314. getCheckOption(id).then( response => {
  315. this.form = response.data;
  316. this.open = true;
  317. this.title = "修改检查项选项";
  318. });
  319. },
  320. /** 提交按钮 */
  321. submitForm() {
  322. this.$refs["form"].validate(valid => {
  323. if (valid) {
  324. if (this.dialogType == 1) {
  325. addCheckOption(this.form).then( response => {
  326. this.msgSuccess("新增成功");
  327. this.open = false;
  328. this.getList();
  329. });
  330. } else if(this.dialogType == 2) {
  331. updateCheckOption(this.form).then( response => {
  332. this.msgSuccess("修改成功");
  333. this.open = false;
  334. this.getList();
  335. });
  336. }
  337. }
  338. });
  339. },
  340. /** 删除按钮操作 */
  341. handleDelete(row) {
  342. const ids = row.id || this.ids;
  343. this.$confirm('是否确认删除检查项?', "警告", {
  344. confirmButtonText: "确定",
  345. cancelButtonText: "取消",
  346. type: "warning"
  347. }).then(function() {
  348. return delCheckOption(ids);
  349. }).then(() => {
  350. this.getList();
  351. this.msgSuccess("删除成功");
  352. }).catch(() => {});
  353. },
  354. /** 导出按钮操作 */
  355. handleExport() {
  356. this.download('laboratory/checkOption/export', {
  357. ...this.queryParams
  358. }, `检查项模板.xlsx`)
  359. },
  360. handleAvatarSuccess(res, file) {
  361. if(res.code == 200){
  362. this.msgSuccess("导入成功")
  363. this.importOpen = false;
  364. this.getList();
  365. }else{
  366. this.msgError(res.msg);
  367. }
  368. },
  369. beforeAvatarUpload(file) {
  370. let type = false;
  371. console.log('file',file);
  372. if (file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type == 'application/vnd.ms-excel') {
  373. type = true;
  374. }else{
  375. this.$message.error('只能上传xls/xlsx格式文件');
  376. type = false;
  377. }
  378. return type;
  379. },
  380. }
  381. };
  382. </script>
  383. <style scoped lang="scss">
  384. .checkOption{
  385. flex:1;
  386. display: flex;
  387. flex-direction: column;
  388. overflow: hidden !important;
  389. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  390. padding:20px!important;
  391. .checkOptionPage{
  392. flex:1;
  393. display: flex;
  394. flex-direction: column;
  395. overflow: hidden !important;
  396. }
  397. }
  398. </style>