YpPlanDetails.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class="layout_display_flex_y">
  3. <div style="margin-bottom: 6px; background-color: #fff;">
  4. <el-input v-model="totalFee" class="w-50 m-2" style="width: 240px;font-size: larger" disabled>
  5. <template #prepend>总费用 </template>
  6. </el-input>
  7. <el-input v-model="totalFeeUpdate" class="w-50 m-2" style="width: 240px;font-size: larger; margin-left: 5px" disabled>
  8. <template #prepend>审核费用 </template>
  9. </el-input>
  10. <el-input v-model="content" class="w-50 m-2" style="width: 300px; margin-left: 5px">
  11. <template #prepend>审核意见 </template>
  12. </el-input>
  13. <el-button type="primary" icon="Check" @click="saveYpPlanData" style="margin-left: 5px">审核</el-button>
  14. </div>
  15. <div class="layout_container">
  16. <div class="layout_main layout_el-table">
  17. <el-table :data="showed_data" @sort-change="sort_charge" border stripe highlight-current-row>
  18. <el-table-column type="index" label="序号" width="60" fixed/>
  19. <el-table-column prop="remark" label="备注" width="100" fixed/>
  20. <el-table-column prop="supplyName" label="药品供应商" width="200" show-overflow-tooltip fixed/>
  21. <el-table-column prop="drugName" label="药品名称" width="200" show-overflow-tooltip fixed/>
  22. <el-table-column prop="specification" label="规格" width="150" show-overflow-tooltip/>
  23. <el-table-column prop="packRetprice1" label="零售价" width="100"/>
  24. <el-table-column prop="buyPrice1" label="购入价" width="100"/>
  25. <el-table-column prop="buyAmount" label="采购计划" width="100">
  26. <template #default="scope">
  27. <el-input v-model.number="scope.row.buyAmount" size="small" @change="buyAmountCharge(scope.row)" />
  28. </template>
  29. </el-table-column>
  30. <el-table-column prop="buyMoney" label="购入金额" width="100" sortable/>
  31. <el-table-column prop="unit" label="单位" width="60" />
  32. <el-table-column prop="amount" label="库存量" width="100" />
  33. <el-table-column prop="manuName" label="制药厂" width="150" show-overflow-tooltip/>
  34. <el-table-column prop="amount3" label="3天用量" width="100" />
  35. <el-table-column prop="amount7" label="7天用量" width="100" />
  36. <el-table-column prop="amount14" label="14天用量" width="100" />
  37. <el-table-column prop="amount30" label="30天用量" width="100" />
  38. <el-table-column prop="amount60" label="60天用量" width="100" />
  39. <el-table-column prop="days" label="可用天数" width="100" />
  40. <el-table-column prop="impDate" label="导入时间" width="140" />
  41. </el-table>
  42. </div>
  43. <div>
  44. <el-pagination :current-page="currentPageMx" :page-size="pageSizeMx" :page-sizes="[10, 15, 20, 25]"
  45. :total="ypPlanDetailData.length" layout="total, sizes, prev, pager, next, jumper"
  46. style="margin-top: 5px" @size-change="handleSizeChangeMx"
  47. @current-change="handleCurrentChangeMx">
  48. </el-pagination>
  49. </div>
  50. </div>
  51. </div>
  52. </template>
  53. <script setup name="YpPlanDetails">
  54. import { ref, onMounted, nextTick, watch } from 'vue'
  55. import {updateYpPlanAuditData, saveYpPlanDetail} from "@/api/yp-inventory/yp-plan-info.js";
  56. import {ElMessage, ElMessageBox} from "element-plus";
  57. const props = defineProps({
  58. ypPlanDetails: {
  59. type: Object,
  60. default: {}
  61. },
  62. formData: {
  63. type: Object,
  64. default: {}
  65. },
  66. zfy: {
  67. type: Number,
  68. default: 0
  69. }
  70. })
  71. const ypPlanDetailData = ref([])
  72. const totalFee = ref(0)
  73. const totalFeeUpdate = ref(0)
  74. const content = ref('')
  75. const form = ref({})
  76. const emit = defineEmits(['close', 'closeYpPlanDetails'])
  77. const showed_data = ref([])
  78. const pageSizeMx = ref(20)
  79. const currentPageMx = ref(1)
  80. const handleSizeChangeMx = (val) => {
  81. pageSizeMx.value = val
  82. showed_data.value = props.ypPlanDetails.slice((currentPageMx.value - 1) * pageSizeMx.value, currentPageMx.value * pageSizeMx.value)
  83. }
  84. const handleCurrentChangeMx = (val) => {
  85. currentPageMx.value = val
  86. showed_data.value = props.ypPlanDetails.slice((currentPageMx.value - 1) * pageSizeMx.value, currentPageMx.value * pageSizeMx.value)
  87. }
  88. onMounted( () => {
  89. nextTick(() => {
  90. ypPlanDetailData.value = props.ypPlanDetails.sort(sortFun('buyMoney', false))
  91. form.value = props.formData
  92. totalFee.value = props.zfy
  93. totalFeeUpdate.value = props.zfy
  94. showed_data.value = ypPlanDetailData.value.slice(0, pageSizeMx.value)
  95. })
  96. })
  97. watch(() => props.ypPlanDetails, () => {
  98. ypPlanDetailData.value = props.ypPlanDetails
  99. form.value = props.formData
  100. totalFee.value = props.zfy
  101. totalFeeUpdate.value = props.zfy
  102. showed_data.value = props.ypPlanDetails.slice((currentPageMx.value - 1) * pageSizeMx.value, currentPageMx.value * pageSizeMx.value)
  103. })
  104. // 排序改变事件
  105. const sort_charge = (column) => {
  106. currentPageMx.value = 1
  107. if(column.order === null){
  108. // 默认按照购入价的降序排序
  109. ypPlanDetailData.value = ypPlanDetailData.value.sort(sortFun('buyFee', false))
  110. } else {
  111. ypPlanDetailData.value = ypPlanDetailData.value.sort(sortFun(column.prop, column.order === 'ascending'))
  112. }
  113. showed_data.value = ypPlanDetailData.value.slice(0, pageSizeMx.value) // 排序完显示到第一页
  114. }
  115. // 排序通用方法
  116. const sortFun = (attr, rev) => {
  117. // 第一个参数传入info里面的prop表示排的是哪一列,第二个参数是升还是降排序
  118. if(rev === undefined){
  119. rev = 1
  120. } else {
  121. rev = (rev) ? 1 : -1
  122. }
  123. return function(a, b){
  124. a = a[attr]
  125. b = b[attr]
  126. if(a < b){
  127. return rev * -1
  128. }
  129. if(a > b){
  130. return rev * 1
  131. }
  132. return 0
  133. }
  134. }
  135. // 根据修改的购入计划(量)计算购入金额
  136. const buyAmountCharge = (row) => {
  137. let dj = row.buyMoney
  138. let money = (row.buyAmount * row.buyPrice1).toFixed(2)
  139. if(money.endsWith(".00")){
  140. row.buyMoney = money.replace(".00", "")
  141. } else {
  142. row.buyMoney = money
  143. }
  144. totalFeeUpdate.value = (totalFeeUpdate.value - dj + parseFloat(row.buyMoney)).toFixed(2)
  145. }
  146. // 保存审核内容
  147. const saveYpPlanData = () => {
  148. ElMessageBox.confirm("确定审核?", {
  149. cancelButtonText: '取消',
  150. confirmButtonText: '确定',
  151. type: 'warning',
  152. distinguishCancelAndClose: true,
  153. dangerouslyUseHTMLString: true
  154. }).then(() => {
  155. saveYpPlanDetail(ypPlanDetailData.value).then((res) => {
  156. if (res.cg) {
  157. ElMessage({
  158. type: "success",
  159. message: res.cg,
  160. duration: 2500,
  161. showClose: true,
  162. });
  163. updateYpPlanAudit()
  164. }
  165. })
  166. })
  167. }
  168. // 保存审核意见等内容
  169. const updateYpPlanAudit = () => {
  170. form.value.totalFee = totalFeeUpdate.value
  171. form.value.content = content.value
  172. updateYpPlanAuditData(form.value)
  173. .then((res) => {
  174. if (res.cg) {
  175. ElMessage({
  176. type: "success",
  177. message: res.cg,
  178. duration: 2500,
  179. showClose: true,
  180. });
  181. emit('closeYpPlanDetails', true)
  182. }
  183. })
  184. .catch(() => {
  185. ElMessage({
  186. type: "error",
  187. message: '药品计划意见审核失败!',
  188. duration: 2500,
  189. showClose: true,
  190. });
  191. })
  192. }
  193. </script>