index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <div class="layout_display_flex_y">
  3. <div class="obviousBox" style="margin-bottom: 6px;">
  4. <searchArea :searchData="searchData" @submit="searchByForm"></searchArea>
  5. </div>
  6. <div class="layout_display_flex_y" style="height: 85%">
  7. <div style="background-color: #fff;padding: 8px">
  8. <!-- <el-button type="primary" icon="Search" @click="queryItem" style="margin-left: 5px">查询</el-button> -->
  9. <el-button type="primary" icon="Download" @click="onAddItem"
  10. style="margin-left: 5px">导入物资申报表</el-button>
  11. <el-input v-model="searchName" style="width: 200px;margin-left: 5px" placeholder="输入物资名称">
  12. <template #prepend>
  13. <el-icon icon="Search" @click="handleSearch" style="cursor: pointer;">
  14. <search />
  15. </el-icon>
  16. </template>
  17. </el-input>
  18. <el-button type="success" @click="onAddItem"
  19. style="margin-left: 5px;">保 存</el-button>
  20. </div>
  21. <el-table
  22. :data="ypClassData.slice(pageSizeClass * (currentPageClass - 1), pageSizeClass * currentPageClass)"
  23. border style="width: 100%" height="100%" stripe highlight-current-row class="ypClassTable normal-size">
  24. <el-table-column fixed="left" label="操作" width="80">
  25. <template #default>
  26. <el-button type="danger" size="small" @click="handleClick">
  27. 删 除
  28. </el-button>
  29. <!-- <el-button link type="primary" size="small">Edit</el-button> -->
  30. </template>
  31. </el-table-column>
  32. <el-table-column type="index" prop="index" label="序号">
  33. </el-table-column>
  34. <el-table-column prop="code" label="项目编码">
  35. </el-table-column>
  36. <el-table-column prop="name" label="项目名称">
  37. </el-table-column>
  38. <el-table-column prop="name" label="规格">
  39. </el-table-column>
  40. <el-table-column prop="name" label="单位">
  41. </el-table-column>
  42. <el-table-column prop="name" label="计划数量">
  43. </el-table-column>
  44. <el-table-column prop="name" label="库存数量">
  45. </el-table-column>
  46. <el-table-column prop="name" label="购进数量">
  47. <template #default="scope">
  48. <el-input v-model="scope.row.name"></el-input>
  49. </template>
  50. </el-table-column>
  51. <el-table-column prop="name" label="审批数量">
  52. <template #default="scope">
  53. <el-input v-model="scope.row.name"></el-input>
  54. </template>
  55. </el-table-column>
  56. <el-table-column prop="name" label="单价">
  57. </el-table-column>
  58. <el-table-column fixed="right" prop="delFlag" label="总金额">
  59. </el-table-column>
  60. </el-table>
  61. </div>
  62. </div>
  63. <el-dialog v-model="showDialog" :close-on-click-modal="false" :close-on-press-escape="false" title="审核科室采购计划"
  64. width="100%" destroy-on-close fullscreen>
  65. <!-- <YpPrintName :ypPrintNameDetail="ypPrintNameDetail" @closeYpPrintNameEditFor="closeYpPrintName" /> -->
  66. <info :currentEditCode="currentEditCode"></info>
  67. </el-dialog>
  68. </template>
  69. <script setup name="YpDict">
  70. import { ref, onMounted, nextTick } from 'vue'
  71. import { ElMessage, ElMessageBox } from 'element-plus'
  72. import {
  73. selectYpClass, saveYpClass, delYpClassByCode,
  74. selectDrugKind,
  75. } from '@/api/yp-dict/yp-dict-base.js'
  76. import searchArea from '@/components/searchArea/index.vue';
  77. import info from '@/views/logisticsMaterials/procurement/departmentProcurementPlanReview/info.vue';
  78. const editableTabsValue = ref('ypClass')
  79. const msgTip = '分类编码(code)有变更,原始字典记录存在关联,请谨慎做更改,是否确认!!!'
  80. const delFlagOptions = [{ code: '0', name: '启用' }, { code: '1', name: '停用' }]
  81. const searchData = ref([
  82. {
  83. label: '请领月份',
  84. key: 'vehicleType',
  85. type: 'monthDataPicker',
  86. value: '',
  87. },
  88. ])
  89. const searchName = ref("")
  90. const pageSizeClass = ref(20)
  91. const currentPageClass = ref(1)
  92. const handleSizeChangeClass = (val) => {
  93. pageSizeClass.value = val
  94. }
  95. const handleCurrentChangeClass = (val) => {
  96. currentPageClass.value = val
  97. }
  98. const pageSizeKind = ref(20)
  99. const currentPageKind = ref(1)
  100. const pageSizeDosage = ref(20)
  101. const currentPageDosage = ref(1)
  102. const pageSizeUnit = ref(20)
  103. const currentPageUnit = ref(1)
  104. const pageSizeSupply = ref(20)
  105. const currentPageSupply = ref(1)
  106. const pageSizeManuFactory = ref(20)
  107. const currentPageManuFactory = ref(1)
  108. const ypClassData = ref([])
  109. const drugKindData = ref([])
  110. const ypDosageData = ref([])
  111. const ypUnitData = ref([])
  112. const ypChargeGroupData = ref([])
  113. const visibleFlagData = ref([])
  114. const ypSupplyData = ref([])
  115. const ypManuFactoryData = ref([])
  116. let showDialog = ref(false)
  117. const text = ref('')
  118. onMounted(() => {
  119. nextTick(() => {
  120. queryYpClass()
  121. })
  122. })
  123. //搜索表单方法
  124. const searchByForm = (form) => {
  125. console.log("search", form)
  126. }
  127. // 查询药品字典-药性字典
  128. const queryYpClass = () => {
  129. selectYpClass(text.value)
  130. .then((res) => {
  131. res.forEach(row => {
  132. // 是否标记
  133. row['isEdit'] = false
  134. // 是否新增
  135. row['isAdd'] = false
  136. })
  137. ypClassData.value = res
  138. })
  139. .catch(() => {
  140. ypClassData.value = []
  141. })
  142. }
  143. // 查询药品字典-药品分类字典
  144. const queryDrugKind = () => {
  145. selectDrugKind(text.value)
  146. .then((res) => {
  147. res.forEach(row => {
  148. // 是否标记
  149. row['isEdit'] = false
  150. // 是否新增
  151. row['isAdd'] = false
  152. })
  153. drugKindData.value = res
  154. })
  155. .catch(() => {
  156. drugKindData.value = []
  157. })
  158. }
  159. // 查询
  160. const queryItem = () => {
  161. if (editableTabsValue.value === 'ypClass') {
  162. queryYpClass()
  163. } else if (editableTabsValue.value === 'drugKind') {
  164. queryDrugKind()
  165. }
  166. }
  167. const handleSearch = () => {
  168. showDialog.value = true
  169. }
  170. // 新增行
  171. const onAddItem = () => {
  172. showDialog.value = true
  173. return
  174. }
  175. // 药品字典-药性字典增删改存开始
  176. // 编辑
  177. const editYpClass = (row) => {
  178. // 备份原始数据
  179. row['oldRow'] = JSON.parse(JSON.stringify(row))
  180. row.isEdit = true
  181. }
  182. // 取消
  183. const cancelYpClass = (row) => {
  184. // 如果是新增的数据
  185. if (row.isAdd) {
  186. ypClassData.value.splice(ypClassData.value.length - 1, 1)
  187. } else {
  188. // 不是新增的数据 还原数据
  189. for (const i in row.oldRow) {
  190. row[i] = row.oldRow[i]
  191. }
  192. }
  193. }
  194. // 保存
  195. const updateYpClass = (row) => {
  196. if (!row.code || !row.name) {
  197. ElMessage({
  198. type: "warning",
  199. message: "药性字典编码或名称不存在,请检查!",
  200. duration: 2500,
  201. showClose: true,
  202. });
  203. return
  204. }
  205. if (row.isAdd) {
  206. let fe = 0
  207. for (let num in ypClassData.value) {
  208. if (ypClassData.value[num].code === row.code) {
  209. fe++
  210. }
  211. }
  212. if (fe === 2) {
  213. ElMessage({
  214. type: "warning",
  215. message: "存在重复的药性字典,请核对!",
  216. duration: 2500,
  217. showClose: true,
  218. });
  219. } else {
  220. callSaveYpClass(row, null)
  221. }
  222. } else {
  223. let oldCode = row.oldRow.code
  224. if (oldCode !== row.code) {
  225. ElMessageBox.confirm(msgTip, {
  226. cancelButtonText: '取消',
  227. confirmButtonText: '确定',
  228. type: 'warning',
  229. distinguishCancelAndClose: true,
  230. dangerouslyUseHTMLString: true
  231. }).then(() => {
  232. callSaveYpClass(row, oldCode)
  233. }).catch((action) => {
  234. if (action === 'cancel') {
  235. queryYpClass()
  236. }
  237. })
  238. } else {
  239. callSaveYpClass(row, oldCode)
  240. }
  241. }
  242. }
  243. const callSaveYpClass = (row, oldCode) => {
  244. let title = '请确认是否保存<span style="color:#d12020;">' + row.name + '</span>?'
  245. ElMessageBox.confirm(title, {
  246. cancelButtonText: '取消',
  247. confirmButtonText: '确定',
  248. type: 'warning',
  249. distinguishCancelAndClose: true,
  250. dangerouslyUseHTMLString: true
  251. }).then(() => {
  252. saveYpClass(row).then((res) => {
  253. ElMessage({
  254. type: "success",
  255. message: res.cg,
  256. duration: 2500,
  257. showClose: true,
  258. });
  259. if (oldCode !== null && oldCode !== row.code) {
  260. // 删除原始数据
  261. delYpClassByCode(oldCode).then((res) => {
  262. queryYpClass()
  263. })
  264. } else {
  265. queryYpClass()
  266. }
  267. })
  268. }).catch((action) => {
  269. if (action === 'cancel') {
  270. queryYpClass()
  271. }
  272. })
  273. }
  274. const deleteYpClass = (index, row) => {
  275. let title = '请确认是否删除<span style="color:#d12020;">' + row.name + '</span>?'
  276. ElMessageBox.confirm(title, {
  277. cancelButtonText: '取消',
  278. confirmButtonText: '确定',
  279. type: 'warning',
  280. distinguishCancelAndClose: true,
  281. dangerouslyUseHTMLString: true
  282. }).then(() => {
  283. delYpClassByCode(row.code).then((res) => {
  284. ElMessage({
  285. type: "success",
  286. message: res.cg,
  287. duration: 2500,
  288. showClose: true,
  289. });
  290. queryYpClass()
  291. })
  292. }).catch((action) => {
  293. if (action === 'cancel') {
  294. queryYpClass()
  295. }
  296. })
  297. }
  298. const currentEditCode = ref('')
  299. const tableEdit = (row) => {
  300. currentEditCode.value = row.code
  301. }
  302. </script>
  303. <style lang="scss" deep>
  304. .el-dialog__body {
  305. // padding: 0 16px;
  306. // height: calc(100% - 25px);
  307. }
  308. .el-tabs {
  309. height: calc(100% - 27px);
  310. .el-tabs__content {
  311. padding: 5px;
  312. height: calc(100% - 27px);
  313. }
  314. .el-tab-pane {
  315. height: calc(100% - 27px);
  316. overflow: auto;
  317. }
  318. .el-table__inner-wrapper {
  319. height: calc(100% - 10px) !important;
  320. }
  321. }
  322. .el-table .warning-row {
  323. --el-table-tr-bg-color: #dd7694;
  324. }
  325. .search-select-pre {
  326. padding: 0 12px;
  327. color: var(--el-text-color-regular);
  328. background: var(--el-fill-color-light);
  329. border-right: 1px solid var(--el-border-color);
  330. --el-select-input-padding-left: '0'
  331. }
  332. </style>