index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <div class="query-box">
  5. <div class="query-box__left">
  6. <el-form-item label="" prop="communityId">
  7. <el-select style="width:160px" v-model="queryParams.communityId"
  8. placeholder="请选择医共体" size="small" :clearable="false"
  9. @change="getMechanismList()"
  10. >
  11. <el-option v-for="item in cascade[0]" :key="item.id" :value="item.id" :label="item.name"
  12. :disabled="item.disabled"></el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="" prop="mechanismId">
  16. <el-select style="width:160px" v-model="queryParams.mechanismId"
  17. placeholder="请选择医疗机构" size="small" :clearable="false"
  18. @change="getDeptList()"
  19. >
  20. <el-option v-for="item in cascade[1]" :key="item.id" :value="item.id" :label="item.name"
  21. :disabled="item.disabled"></el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="" prop="mechanismId">
  25. <el-select style="width:160px" v-model="queryParams.deptId"
  26. placeholder="请选择科室" size="small" clearable
  27. >
  28. <el-option v-for="item in cascade[2]" :key="item.id" :value="item.id" :label="item.name"
  29. :disabled="item.disabled"></el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="" prop="herbsCode">
  33. <el-input style="width:160px" v-model="queryParams.herbsCode" placeholder="医疗机构药品编码" size="small"
  34. clearable
  35. @keyup.enter.native="handleQuery"
  36. ></el-input>
  37. </el-form-item>
  38. <el-form-item label="" prop="herbsName">
  39. <el-input style="width:160px" v-model="queryParams.herbsName" placeholder="医疗机构药品名称" size="small"
  40. clearable
  41. @keyup.enter.native="handleQuery"
  42. ></el-input>
  43. </el-form-item>
  44. <el-form-item>
  45. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  46. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  47. <el-button type="primary" plain icon="el-icon-plus" size="mini"
  48. v-hasPermi="['drugs:map:create']" @click="handleEdit()"
  49. >新增
  50. </el-button>
  51. <el-button type="default" plain icon="el-icon-upload2" size="mini"
  52. :loading="importing"
  53. v-hasPermi="['drugs:map:import']" @click="startUpload = true;"
  54. >导入
  55. </el-button>
  56. <el-button type="default" plain icon="el-icon-download" size="mini"
  57. :loading="exporting"
  58. v-hasPermi="['drugs:map:export']" @click="handleExport()"
  59. >导出
  60. </el-button>
  61. </el-form-item>
  62. </div>
  63. </div>
  64. </el-form>
  65. <el-table v-loading="loading" :data="list" size="mini" border>
  66. <el-table-column type="index" width="55" align="center" label="序号"/>
  67. <el-table-column prop="drugsName" label="系统药品名称" align="center"/>
  68. <el-table-column prop="drugsId" label="系统药品编码" align="center"></el-table-column>
  69. <el-table-column prop="herbsName" label="医疗机构药品名称" align="center"></el-table-column>
  70. <el-table-column prop="herbsCode" label="医疗机构药品编码" align="center"></el-table-column>
  71. <el-table-column prop="herbsSpecsName" label="医疗机构药品规格" align="center"></el-table-column>
  72. <el-table-column prop="herbsSpecsCode" label="医疗机构药品规格编码" align="center"></el-table-column>
  73. <el-table-column prop="createTime" label="创建时间" align="center"></el-table-column>
  74. <el-table-column prop="updateTime" label="修改时间" align="center"></el-table-column>
  75. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="80" fixed="right">
  76. <template slot-scope="scope">
  77. <el-button style="width: 40px;" type="danger" size="mini"
  78. v-hasPermi="['drugs:map:remove']"
  79. @click="handleDelete(scope.row)"
  80. >删除
  81. </el-button>
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. <pagination
  86. v-show="total > 0"
  87. :total="total"
  88. :page.sync="queryParams.pageNum"
  89. :limit.sync="queryParams.pageSize"
  90. @pagination="getList"
  91. />
  92. <!-- 添加或修改入库单对话框 -->
  93. <el-dialog :fullscreen="false" :title="title" :visible.sync="open" width="80%" append-to-body size="mini"
  94. destroy-on-close>
  95. <edit :community-id="model.communityId" :mechanism-id="model.mechanismId" :dept-id="model.deptId"
  96. @close="open = false;$event && getList()"
  97. />
  98. </el-dialog>
  99. <el-dialog :fullscreen="false" title="药品映射" :visible.sync="startUpload" width="400px" append-to-body
  100. size="mini">
  101. <upload
  102. :uploading="uploading" @upload="handleImport($event)"
  103. :downloading="downloading" @download="handleDownload()"
  104. />
  105. </el-dialog>
  106. </div>
  107. </template>
  108. <script>
  109. import selectTable from '@/components/selectTable/selectTable.vue'
  110. import Edit from "./edit.vue";
  111. import Upload from "./upload.vue";
  112. import {listCommunity} from "@/api/system/community";
  113. import {listMechanismId} from "@/api/medical/mechanism";
  114. import {getByMechanismId} from "@/api/medical/dept";
  115. import {drugsMap, drugsMapDelete, drugsMapExport, drugsMapImport, drugsMapImportTemplate} from "@/api/drugs/drugs";
  116. export default {
  117. name: "DrugsMap",
  118. computed: {},
  119. components: {
  120. Edit,
  121. Upload,
  122. selectTable
  123. },
  124. data() {
  125. return {
  126. cascade: [[], [], []],
  127. list: [],
  128. model: {},
  129. // 遮罩层
  130. loading: false,
  131. exporting: false,
  132. importing: false,
  133. uploading: false,
  134. downloading: false,
  135. startUpload: false,
  136. // 显示搜索条件
  137. showSearch: true,
  138. // 总条数
  139. total: 0,
  140. // 是否显示弹出层
  141. open: false,
  142. // 弹出层标题
  143. title: "药品映射",
  144. // 查询参数
  145. queryParams: {
  146. pageNum: 1,
  147. pageSize: 10,
  148. pharmacyId: window.localStorage.getItem("pharmacyId"),
  149. herbsCode: '',
  150. herbsName: '',
  151. communityId: '',
  152. mechanismId: '',
  153. deptId: '',
  154. },
  155. backupsParams: {},
  156. };
  157. },
  158. created() {
  159. this.resetQuery();
  160. },
  161. methods: {
  162. /** 查询医共体列表 */
  163. async getCommunityList() {
  164. try {
  165. const {rows} = await listCommunity();
  166. this.$set(this.cascade, 0, rows.map(item => (item.disabled = item.state === '0', item)))
  167. } catch (error) {
  168. this.$set(this.cascade, 0, []);
  169. }
  170. const list = this.cascade[0];
  171. const select = this.queryParams.communityId;
  172. if (list.length && !(select && list.find(item => item.id === select))) this.queryParams.communityId = list[0].id;
  173. },
  174. /** 查询医疗机构列表 */
  175. async getMechanismList() {
  176. try {
  177. if (!this.queryParams.communityId) throw '';
  178. const {data: rows} = await listMechanismId(this.queryParams.communityId);
  179. this.$set(this.cascade, 1, rows.map(item => (item.disabled = item.state === '0', item)))
  180. } catch (error) {
  181. this.$set(this.cascade, 1, []);
  182. }
  183. const list = this.cascade[1];
  184. const select = this.queryParams.mechanismId;
  185. if (list.length && !(select && list.find(item => item.id === select))) this.queryParams.mechanismId = list[0].id;
  186. this.$set(this.cascade, 2, [])
  187. this.queryParams.deptId = '';
  188. },
  189. /** 查询科室列表 */
  190. async getDeptList() {
  191. try {
  192. if (!this.queryParams.mechanismId) throw '';
  193. const {data: rows} = await getByMechanismId(this.queryParams.mechanismId);
  194. this.$set(this.cascade, 2, rows.map(item => (item.disabled = item.state === '0', item)))
  195. } catch (error) {
  196. this.$set(this.cascade, 2, []);
  197. }
  198. const select = this.queryParams.deptId;
  199. if (select && !this.cascade[2].find(item => item.id === select)) this.queryParams.deptId = '';
  200. },
  201. async getList() {
  202. this.queryParams.communityId = this.backupsParams.communityId;
  203. this.queryParams.mechanismId = this.backupsParams.mechanismId;
  204. this.queryParams.deptId = this.backupsParams.deptId;
  205. this.loading = true;
  206. try {
  207. const {rows, total} = await drugsMap(this.queryParams);
  208. this.list = rows;
  209. this.total = total;
  210. } catch (error) {}
  211. this.loading = false;
  212. },
  213. /** 搜索按钮操作 */
  214. handleQuery() {
  215. const {communityId, mechanismId, deptId} = this.queryParams;
  216. this.backupsParams = {communityId, mechanismId, deptId}
  217. this.queryParams.pageNum = 1;
  218. this.getList();
  219. },
  220. /** 重置按钮操作 */
  221. async resetQuery() {
  222. this.resetForm("queryForm");
  223. /*this.queryParams.date = [
  224. dayjs().startOf('day').format('YYYY-MM-DD HH:mm:ss'),
  225. dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss'),
  226. ]*/
  227. this.queryParams.communityId = this.backupsParams.communityId;
  228. await this.getCommunityList();
  229. if (!this.queryParams.communityId) return;
  230. this.queryParams.mechanismId = this.backupsParams.mechanismId;
  231. await this.getMechanismList();
  232. if (!this.queryParams.mechanismId) return;
  233. this.handleQuery();
  234. await this.getDeptList()
  235. },
  236. handleEdit() {
  237. this.model = {...this.backupsParams};
  238. this.editable = true;
  239. this.open = true;
  240. },
  241. handleDelete(row) {
  242. const ids = row.id || this.ids;
  243. this.$confirm("是否删除该药品映射?", "警告", {
  244. confirmButtonText: "确定",
  245. cancelButtonText: "取消",
  246. type: "warning",
  247. })
  248. .then(() => drugsMapDelete(ids))
  249. .then(() => {
  250. this.open = false;
  251. this.getList();
  252. this.msgSuccess("删除成功");
  253. })
  254. .catch(() => {});
  255. },
  256. async handleExport() {
  257. this.exporting = true;
  258. try {
  259. const {blob, name = ''} = await drugsMapExport(this.backupsParams);
  260. this.msgSuccess(`${name} 下载成功`);
  261. } catch (error) {}
  262. this.exporting = false;
  263. },
  264. async handleDownload() {
  265. this.downloading = true;
  266. try {
  267. const {blob, name = ''} = await drugsMapImportTemplate(this.backupsParams);
  268. this.msgSuccess(`${name} 下载成功`);
  269. } catch (e) { }
  270. this.downloading = false;
  271. },
  272. async handleImport(file) {
  273. this.uploading = true;
  274. try {
  275. const {msg} = await drugsMapImport(Object.assign({file}, this.backupsParams));
  276. this.msgSuccess(msg);
  277. this.startUpload = false;
  278. this.getList().then();
  279. } catch (e) {}
  280. this.uploading = false;
  281. },
  282. },
  283. };
  284. </script>
  285. <style scoped>
  286. .el-input--small .el-input__inner {
  287. height: 36px;
  288. line-height: 36px;
  289. }
  290. </style>