index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="经络穴位名称" prop="vesselName">
  5. <el-input
  6. v-model="queryParams.vesselName"
  7. placeholder="经络穴位名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="经络" prop="vessel">
  14. <el-select filterable v-model="queryParams.vessel" placeholder="请选择经络" clearable size="small">
  15. <el-option
  16. v-for="dict in vesselOptions"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="部位" prop="region">
  24. <el-select filterable v-model="queryParams.region" placeholder="请选择部位" clearable size="small">
  25. <el-option
  26. v-for="dict in regionOptions"
  27. :key="dict.dictValue"
  28. :label="dict.dictLabel"
  29. :value="dict.dictValue"
  30. />
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="状态" prop="status">
  34. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  35. <el-option
  36. v-for="dict in statusOptions"
  37. :key="dict.dictValue"
  38. :label="dict.dictLabel"
  39. :value="dict.dictValue"
  40. />
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item>
  44. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  45. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  46. </el-form-item>
  47. </el-form>
  48. <el-row :gutter="10" class="mb8">
  49. <el-col :span="1.5">
  50. <el-button
  51. type="primary"
  52. plain
  53. icon="el-icon-plus"
  54. size="mini"
  55. @click="handleAdd"
  56. v-hasPermi="['his:vessel:add']"
  57. >新增</el-button>
  58. </el-col>
  59. <el-col :span="1.5">
  60. <el-button
  61. type="success"
  62. plain
  63. icon="el-icon-edit"
  64. size="mini"
  65. :disabled="single"
  66. @click="handleUpdate"
  67. v-hasPermi="['his:vessel:edit']"
  68. >修改</el-button>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button
  72. type="danger"
  73. plain
  74. icon="el-icon-delete"
  75. size="mini"
  76. :disabled="multiple"
  77. @click="handleDelete"
  78. v-hasPermi="['his:vessel:remove']"
  79. >删除</el-button>
  80. </el-col>
  81. <el-col :span="1.5">
  82. <el-button
  83. type="warning"
  84. plain
  85. icon="el-icon-download"
  86. size="mini"
  87. :loading="exportLoading"
  88. @click="handleExport"
  89. v-hasPermi="['his:vessel:export']"
  90. >导出</el-button>
  91. </el-col>
  92. <el-col :span="1.5">
  93. <el-button
  94. type="info"
  95. plain
  96. icon="el-icon-upload2"
  97. size="mini"
  98. @click="handleImport"
  99. >导入</el-button>
  100. </el-col>
  101. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  102. </el-row>
  103. <el-table height="660" v-loading="loading" :data="vesselList" @selection-change="handleSelectionChange">
  104. <el-table-column type="selection" width="55" align="center" />
  105. <el-table-column label="图片" align="center" prop="imgUrl" >
  106. <template slot-scope="scope">
  107. <el-popover
  108. placement="right"
  109. title=""
  110. trigger="hover">
  111. <img slot="reference" :src="scope.row.imgUrl" width="100px">
  112. <img :src="scope.row.imgUrl" style="max-width: 150px;">
  113. </el-popover>
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="经络穴位名称" align="center" prop="vesselName" />
  117. <el-table-column label="排序" align="center" prop="sort" />
  118. <el-table-column label="经络" align="center" prop="vessel" />
  119. <el-table-column label="部位" align="center" prop="region" />
  120. <el-table-column label="状态" align="center" prop="status">
  121. <template slot-scope="scope">
  122. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="创建时间" align="center" prop="createTime" width="180"/>
  126. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  127. <template slot-scope="scope">
  128. <el-button
  129. size="mini"
  130. type="text"
  131. icon="el-icon-edit"
  132. @click="handleUpdate(scope.row)"
  133. v-hasPermi="['his:vessel:edit']"
  134. >修改</el-button>
  135. <el-button
  136. size="mini"
  137. type="text"
  138. @click="handledetails(scope.row)"
  139. >详情
  140. </el-button>
  141. <el-button
  142. size="mini"
  143. type="text"
  144. icon="el-icon-delete"
  145. @click="handleDelete(scope.row)"
  146. v-hasPermi="['his:vessel:remove']"
  147. >删除</el-button>
  148. </template>
  149. </el-table-column>
  150. </el-table>
  151. <pagination
  152. v-show="total>0"
  153. :total="total"
  154. :page.sync="queryParams.pageNum"
  155. :limit.sync="queryParams.pageSize"
  156. @pagination="getList"
  157. />
  158. <!-- 添加或修改经络管理对话框 -->
  159. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  160. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  161. <el-form-item label="图片" prop="imgUrl">
  162. <el-upload
  163. v-model="form.imgUrl"
  164. class="avatar-uploader"
  165. :action="uploadUrl"
  166. :show-file-list="false"
  167. :on-success="handleAvatarSuccess"
  168. :before-upload="beforeAvatarUpload">
  169. <img v-if="form.imgUrl" :src="form.imgUrl" class="avatar" width="200px">
  170. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  171. </el-upload>
  172. </el-form-item>
  173. <el-form-item label="经络穴位名称" prop="vesselName">
  174. <el-input v-model="form.vesselName" placeholder="请输入经络穴位名称" />
  175. </el-form-item>
  176. <el-form-item label="拼音" prop="pinyin">
  177. <el-input v-model="form.pinyin" placeholder="请输入拼音" />
  178. </el-form-item>
  179. <el-form-item label="功效概述" prop="pinyin">
  180. <el-input v-model="form.actionTitle" placeholder="请输入功效概述" />
  181. </el-form-item>
  182. <el-form-item label="所属经络" prop="vessel">
  183. <el-select v-model="form.vessel" placeholder="请选择经络">
  184. <el-option
  185. v-for="dict in vesselOptions"
  186. :key="dict.dictValue"
  187. :label="dict.dictLabel"
  188. :value="dict.dictValue"
  189. ></el-option>
  190. </el-select>
  191. </el-form-item>
  192. <el-form-item label="部位" prop="region">
  193. <el-select v-model="form.region" placeholder="请选择部位">
  194. <el-option
  195. v-for="dict in regionOptions"
  196. :key="dict.dictValue"
  197. :label="dict.dictLabel"
  198. :value="dict.dictValue"
  199. ></el-option>
  200. </el-select>
  201. </el-form-item>
  202. <el-form-item label="排序" prop="sort">
  203. <el-input-number v-model="form.sort" :min="0" label="请输入排序"></el-input-number>
  204. </el-form-item>
  205. <el-form-item label="描述" prop="descs">
  206. <Editor ref="myeditor" @on-text-change="updateText"/>
  207. </el-form-item>
  208. <el-form-item label="状态">
  209. <el-radio-group v-model="form.status">
  210. <el-radio
  211. v-for="dict in statusOptions"
  212. :key="dict.dictValue"
  213. :label="parseInt(dict.dictValue)"
  214. >{{dict.dictLabel}}</el-radio>
  215. </el-radio-group>
  216. </el-form-item>
  217. </el-form>
  218. <div slot="footer" class="dialog-footer">
  219. <el-button type="primary" @click="submitForm">确 定</el-button>
  220. <el-button @click="cancel">取 消</el-button>
  221. </div>
  222. </el-dialog>
  223. <el-drawer
  224. :with-header="false"
  225. size="75%"
  226. :title="show.title" :visible.sync="show.open">
  227. <vesselDetails ref="Details" />
  228. </el-drawer>
  229. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  230. <el-upload
  231. ref="upload"
  232. :limit="1"
  233. accept=".xlsx, .xls"
  234. :headers="upload.headers"
  235. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  236. :disabled="upload.isUploading"
  237. :on-progress="handleFileUploadProgress"
  238. :on-success="handleFileSuccess"
  239. :auto-upload="false"
  240. drag
  241. >
  242. <i class="el-icon-upload"></i>
  243. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  244. <div class="el-upload__tip text-center" slot="tip">
  245. <div class="el-upload__tip" slot="tip">
  246. <!-- <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的数据 -->
  247. </div>
  248. <span>仅允许导入xls、xlsx格式文件。</span>
  249. <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
  250. </div>
  251. </el-upload>
  252. <div slot="footer" class="dialog-footer">
  253. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  254. <el-button @click="upload.open = false">取 消</el-button>
  255. </div>
  256. </el-dialog>
  257. </div>
  258. </template>
  259. <script>
  260. import { listVessel, getVessel, delVessel, addVessel, updateVessel, exportVessel, importTemplate} from "@/api/his/vessel";
  261. import vesselDetails from '../../components/his/vesselDetails.vue';
  262. import Editor from '@/components/Editor/wang';
  263. import { getToken } from "@/utils/auth";
  264. export default {
  265. name: "Vessel",
  266. components: { Editor ,vesselDetails},
  267. data() {
  268. return {
  269. upload: {
  270. // 是否显示弹出层
  271. open: false,
  272. // 弹出层标题
  273. title: "",
  274. // 是否禁用上传
  275. isUploading: false,
  276. // 是否更新已经存在的用户数据
  277. updateSupport: 0,
  278. // 设置上传的请求头部
  279. headers: { Authorization: "Bearer " + getToken() },
  280. // 上传的地址
  281. url: process.env.VUE_APP_BASE_API + "/his/vessel/importData"
  282. },
  283. show:{
  284. open:false,
  285. },
  286. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  287. baseUrl: process.env.VUE_APP_BASE_API,
  288. // 遮罩层
  289. loading: true,
  290. // 导出遮罩层
  291. exportLoading: false,
  292. // 选中数组
  293. ids: [],
  294. // 非单个禁用
  295. single: true,
  296. // 非多个禁用
  297. multiple: true,
  298. // 显示搜索条件
  299. showSearch: true,
  300. // 总条数
  301. total: 0,
  302. // 经络管理表格数据
  303. vesselList: [],
  304. // 弹出层标题
  305. title: "",
  306. // 是否显示弹出层
  307. open: false,
  308. // 经络字典
  309. vesselOptions: [],
  310. // 部位字典
  311. regionOptions: [],
  312. // 状态字典
  313. statusOptions: [],
  314. // 查询参数
  315. queryParams: {
  316. pageNum: 1,
  317. pageSize: 10,
  318. vesselName: null,
  319. imgUrl: null,
  320. sort: null,
  321. vessel: null,
  322. region: null,
  323. descs: null,
  324. createTime: null,
  325. status: null
  326. },
  327. // 表单参数
  328. form: {},
  329. // 表单校验
  330. rules: {
  331. vesselName: [
  332. { required: true, message: "筋络穴位名称不能为空", trigger: "blur" }
  333. ],
  334. descs: [
  335. { required: true, message: "描述不能为空", trigger: "blur" }
  336. ],
  337. }
  338. };
  339. },
  340. created() {
  341. this.getList();
  342. this.getDicts("sys_vessel").then(response => {
  343. this.vesselOptions = response.data;
  344. });
  345. this.getDicts("sys_vessel_region").then(response => {
  346. this.regionOptions = response.data;
  347. });
  348. this.getDicts("sys_company_status").then(response => {
  349. this.statusOptions = response.data;
  350. });
  351. },
  352. methods: {
  353. /** 导入按钮操作 */
  354. handleImport() {
  355. this.upload.title = "导入";
  356. this.upload.open = true;
  357. },
  358. /** 下载模板操作 */
  359. importTemplate() {
  360. importTemplate().then(response => {
  361. this.download(response.msg);
  362. });
  363. },
  364. // 文件上传中处理
  365. handleFileUploadProgress(event, file, fileList) {
  366. this.upload.isUploading = true;
  367. },
  368. // 文件上传成功处理
  369. handleFileSuccess(response, file, fileList) {
  370. this.upload.open = false;
  371. this.upload.isUploading = false;
  372. this.$refs.upload.clearFiles();
  373. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  374. this.getList();
  375. },
  376. // 提交上传文件
  377. submitFileForm() {
  378. this.$refs.upload.submit();
  379. },
  380. handledetails(row){
  381. this.show.open=true;
  382. setTimeout(() => {
  383. this.$refs.Details.getDetails(row.id);
  384. }, 1);
  385. },
  386. handleAvatarSuccess(res, file) {
  387. if(res.code==200){
  388. this.form.imgUrl=res.url;
  389. self.$forceUpdate()
  390. }
  391. else{
  392. this.msgError(res.msg);
  393. }
  394. },
  395. updateText(text){
  396. this.form.descs=text
  397. },
  398. beforeAvatarUpload(file) {
  399. const isLt1M = file.size / 1024 / 1024 < 1;
  400. if (!isLt1M) {
  401. this.$message.error('上传图片大小不能超过 1MB!');
  402. }
  403. return isLt1M;
  404. },
  405. /** 查询经络管理列表 */
  406. getList() {
  407. this.loading = true;
  408. listVessel(this.queryParams).then(response => {
  409. this.vesselList = response.rows;
  410. this.total = response.total;
  411. this.loading = false;
  412. });
  413. },
  414. // 取消按钮
  415. cancel() {
  416. this.open = false;
  417. this.reset();
  418. },
  419. // 表单重置
  420. reset() {
  421. this.form = {
  422. id: null,
  423. vesselName: null,
  424. imgUrl: null,
  425. sort: null,
  426. vessel: null,
  427. region: null,
  428. descs: null,
  429. createTime: null,
  430. status: 0
  431. };
  432. this.resetForm("form");
  433. },
  434. /** 搜索按钮操作 */
  435. handleQuery() {
  436. this.queryParams.pageNum = 1;
  437. this.getList();
  438. },
  439. /** 重置按钮操作 */
  440. resetQuery() {
  441. this.resetForm("queryForm");
  442. this.handleQuery();
  443. },
  444. // 多选框选中数据
  445. handleSelectionChange(selection) {
  446. this.ids = selection.map(item => item.id)
  447. this.single = selection.length!==1
  448. this.multiple = !selection.length
  449. },
  450. /** 新增按钮操作 */
  451. handleAdd() {
  452. this.reset();
  453. this.open = true;
  454. setTimeout(() => {
  455. this.$refs.myeditor.setText("");
  456. }, 500);
  457. this.title = "添加经络管理";
  458. },
  459. /** 修改按钮操作 */
  460. handleUpdate(row) {
  461. this.reset();
  462. const id = row.id || this.ids
  463. getVessel(id).then(response => {
  464. this.form = response.data;
  465. this.open = true;
  466. setTimeout(() => {
  467. if(this.form.descs==null){
  468. this.$refs.myeditor.setText("");
  469. }
  470. else{
  471. this.$refs.myeditor.setText(this.form.descs);
  472. }
  473. }, 1);
  474. this.title = "修改经络管理";
  475. });
  476. },
  477. /** 提交按钮 */
  478. submitForm() {
  479. this.$refs["form"].validate(valid => {
  480. if (valid) {
  481. if (this.form.id != null) {
  482. updateVessel(this.form).then(response => {
  483. this.msgSuccess("修改成功");
  484. this.open = false;
  485. this.getList();
  486. });
  487. } else {
  488. addVessel(this.form).then(response => {
  489. this.msgSuccess("新增成功");
  490. this.open = false;
  491. this.getList();
  492. });
  493. }
  494. }
  495. });
  496. },
  497. /** 删除按钮操作 */
  498. handleDelete(row) {
  499. const ids = row.id || this.ids;
  500. this.$confirm('是否确认删除经络管理编号为"' + ids + '"的数据项?', "警告", {
  501. confirmButtonText: "确定",
  502. cancelButtonText: "取消",
  503. type: "warning"
  504. }).then(function() {
  505. return delVessel(ids);
  506. }).then(() => {
  507. this.getList();
  508. this.msgSuccess("删除成功");
  509. }).catch(() => {});
  510. },
  511. /** 导出按钮操作 */
  512. handleExport() {
  513. const queryParams = this.queryParams;
  514. this.$confirm('是否确认导出所有经络管理数据项?', "警告", {
  515. confirmButtonText: "确定",
  516. cancelButtonText: "取消",
  517. type: "warning"
  518. }).then(() => {
  519. this.exportLoading = true;
  520. return exportVessel(queryParams);
  521. }).then(response => {
  522. this.download(response.msg);
  523. this.exportLoading = false;
  524. }).catch(() => {});
  525. }
  526. }
  527. };
  528. </script>
  529. <style>
  530. .avatar-uploader .el-upload {
  531. border: 1px dashed #d9d9d9;
  532. border-radius: 6px;
  533. cursor: pointer;
  534. position: relative;
  535. overflow: hidden;
  536. }
  537. .avatar-uploader .el-upload:hover {
  538. border-color: #409EFF;
  539. }
  540. .avatar-uploader-icon {
  541. font-size: 28px;
  542. color: #8c939d;
  543. width: 150px;
  544. height: 150px;
  545. line-height: 150px;
  546. text-align: center;
  547. }
  548. </style>