MaterialTable.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <div class="material-table">
  3. <el-table :data="tableData" border :max-height="600">
  4. <el-table-column type="index" label="组号" width="60" align="center" />
  5. <el-table-column label="耗材" min-width="300">
  6. <template #default="{row}">
  7. <div class="material-group">
  8. <div class="material-row" style="margin-bottom:10px;">
  9. <el-select v-model="row.consumableId" placeholder="请选择" @change="changeConsumableSelect">
  10. <el-option v-for="pn in suppliesList" :key="pn.id" :label="pn.suppliesName"
  11. :value="pn.id+'_'+row.sn"></el-option>
  12. </el-select>
  13. </div>
  14. </div>
  15. </template>
  16. </el-table-column>
  17. <el-table-column label="规格" width="100" align="center">
  18. <template #default="{row}">
  19. <div class="spec-group">
  20. <span>{{ row.specification }}</span>
  21. </div>
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="用量/次" width="200" align="center">
  25. <template #default="{row}">
  26. <div class="dosage-group">
  27. <div class="dosage-input">
  28. <el-input v-model="row.dosePerTime" placeholder="请输入" class="input-center" >
  29. <template #append>袋</template>
  30. </el-input>
  31. </div>
  32. </div>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="频次" width="100" align="center">
  36. <template #default="{row}">
  37. <span>一天{{row.frequency}}次</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="用量/日" width="100" align="center">
  41. <template #default="{row}">
  42. <span>{{ row.dosePerDay }}</span>
  43. <span class="unit">袋</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="使用天数" width="100" align="center">
  47. <template #default="{row}">
  48. <span>{{ row.usageDays }}天</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="首日" width="80" align="center">
  52. <template #default="{row}">
  53. <span>{{ row.firstDay }}次</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="数量" width="80" align="center">
  57. <template #default="{row}">
  58. <span>{{ row.quantity }}袋</span>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="处方备注" width="200" align="center">
  62. <template #default="{row}">
  63. <el-input v-model="row.prescriptionRemark" :maxlength="100" :show-word-limit="true" />
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="金额" width="80" align="center">
  67. <template #default="{row}">
  68. <span>{{ row.amount }}</span>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <div class="table-footer">
  73. <div class="left-buttons">
  74. <el-button type="primary" plain>登为个人模板</el-button>
  75. <el-button type="primary" plain>批量添加营养品</el-button>
  76. <el-button type="primary" plain>处方模板</el-button>
  77. </div>
  78. <div class="right-summary">
  79. <div class="summary-list">
  80. <div class="summary-item">
  81. <span class="label">处方费用:</span>
  82. <span class="value">¥0.00</span>
  83. </div>
  84. <div class="summary-item">
  85. <span class="label">营养配置费:</span>
  86. <span class="value">¥39.00</span>
  87. </div>
  88. <div class="summary-item total">
  89. <span class="label">总计:</span>
  90. <span class="value">¥39.00</span>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. </template>
  97. <script setup lang="ts">
  98. import {ref,defineProps} from 'vue';
  99. import { listAll } from '@/api/warehouse/suppliesManage';
  100. import { SuppliesManageVO } from '@/api/warehouse/suppliesManage/types';
  101. import { listNutritionConsumable, getNutritionConsumable, delNutritionConsumable, addNutritionConsumable, updateNutritionConsumable } from '@/api/patients/nutritionConsumable';
  102. import {NutritionConsumableForm } from '@/api/patients/nutritionConsumable/types';
  103. import { string } from 'vue-types';
  104. import { json } from 'stream/consumers';
  105. const emit = defineEmits(['update:modelValue']);
  106. const prop=defineProps({
  107. modelValue: {
  108. type: String,
  109. default: () => undefined
  110. },
  111. });
  112. interface TableRow extends NutritionConsumableForm {
  113. sn?: number;
  114. }
  115. // 示例数据
  116. const tableData = ref<TableRow[]>([
  117. {
  118. firstDay:1,
  119. frequency:3,
  120. dosePerTime:1,
  121. dosePerDay:3,
  122. usageDays:1,
  123. quantity:1,
  124. sn: 0
  125. }
  126. ]);
  127. let suppliesList=ref<SuppliesManageVO[]>([]);
  128. const getSuppliesList = async () => {
  129. const res = await listAll();
  130. suppliesList.value = res.rows;
  131. }
  132. // 复制行
  133. const copyRow = (index: number) => {
  134. const newRow = JSON.parse(JSON.stringify(tableData.value[index]));
  135. tableData.value.splice(index + 1, 0, newRow);
  136. };
  137. // 删除行
  138. const deleteRow = (index: number) => {
  139. if (tableData.value.length === 1) return;
  140. tableData.value.splice(index, 1);
  141. };
  142. const changeConsumableSelect = async (id: string) => {
  143. let arr=id.split('_');
  144. for (let item of suppliesList.value) {
  145. if (item.id.toString() != arr[0]) {
  146. continue
  147. }
  148. let row = tableData.value[Number(arr[1])];
  149. row.specification=item.suppliesSpec;
  150. row.amount=item.sellPrice;
  151. break;
  152. }
  153. };
  154. watch(
  155. () => prop.modelValue,
  156. async (val: string) => {
  157. let configData=JSON.parse(val);
  158. const tableData = ref<TableRow[]>([]);
  159. configData.forEach((item:any) => {
  160. let row: TableRow = {
  161. frequency: item.frequency,
  162. usageDays: item.usageDays,
  163. firstDay: item.firstDay,
  164. sn: tableData.value.length
  165. };
  166. row.dosePerTime=0;
  167. tableData.value.push(row);
  168. });
  169. console.log(configData, "?????*************????????????????");
  170. },
  171. { deep: true, immediate: true }
  172. );
  173. onMounted(() => {
  174. getSuppliesList();
  175. });
  176. </script>
  177. <style lang="scss" scoped>
  178. .material-table {
  179. :deep(.el-table) {
  180. // 表头样式
  181. .el-table__header {
  182. th {
  183. background-color: #f5f7fa;
  184. color: #606266;
  185. font-weight: 500;
  186. padding: 8px 0;
  187. height: 40px;
  188. }
  189. }
  190. // 表格行样式
  191. .el-table__row {
  192. td {
  193. padding: 4px 8px;
  194. }
  195. }
  196. }
  197. // 耗材输入框组样式
  198. .material-group {
  199. display: flex;
  200. flex-direction: column;
  201. gap: 8px;
  202. .material-row {
  203. display: flex;
  204. align-items: center;
  205. gap: 8px;
  206. .el-input {
  207. flex: 1;
  208. }
  209. }
  210. }
  211. // 规格组样式
  212. .spec-group {
  213. display: flex;
  214. flex-direction: column;
  215. gap: 20px;
  216. padding: 8px 0;
  217. span {
  218. color: #606266;
  219. font-size: 14px;
  220. }
  221. }
  222. // 用量输入框组样式
  223. .dosage-group {
  224. display: flex;
  225. flex-direction: column;
  226. gap: 8px;
  227. .dosage-input {
  228. display: flex;
  229. align-items: center;
  230. justify-content: center;
  231. gap: 4px;
  232. .input-center {
  233. width: 100px;
  234. :deep(.el-input__inner) {
  235. text-align: center;
  236. }
  237. }
  238. .unit {
  239. color: #909399;
  240. font-size: 14px;
  241. flex-shrink: 0;
  242. }
  243. }
  244. }
  245. // 餐次时间样式
  246. .time-slots {
  247. display: flex;
  248. flex-direction: column;
  249. gap: 8px;
  250. .time-row {
  251. display: flex;
  252. gap: 8px;
  253. .time-group {
  254. display: flex;
  255. align-items: center;
  256. gap: 4px;
  257. :deep(.el-checkbox) {
  258. margin-right: 0;
  259. .el-checkbox__label {
  260. display: none;
  261. }
  262. }
  263. :deep(.el-time-select) {
  264. .el-input {
  265. width: 120px;
  266. }
  267. .el-input__wrapper {
  268. padding: 0 8px;
  269. border-radius: 2px;
  270. box-shadow: 0 0 0 1px #dcdfe6 inset;
  271. &:hover:not(.is-disabled) {
  272. box-shadow: 0 0 0 1px #c0c4cc inset;
  273. }
  274. &.is-disabled {
  275. background-color: #f5f7fa;
  276. box-shadow: 0 0 0 1px #e4e7ed inset;
  277. .el-input__inner {
  278. color: #909399;
  279. -webkit-text-fill-color: #909399;
  280. }
  281. }
  282. }
  283. .el-input__inner {
  284. height: 32px;
  285. text-align: center;
  286. font-size: 14px;
  287. color: #606266;
  288. }
  289. }
  290. }
  291. }
  292. }
  293. // 操作按钮样式
  294. :deep(.el-button--link) {
  295. height: 28px;
  296. padding: 0 8px;
  297. font-size: 13px;
  298. &.el-button--primary {
  299. color: var(--el-color-primary);
  300. &:hover {
  301. color: var(--el-color-primary-light-3);
  302. }
  303. }
  304. &.el-button--danger {
  305. color: var(--el-color-danger);
  306. &:hover {
  307. color: var(--el-color-danger-light-3);
  308. }
  309. }
  310. }
  311. .table-footer {
  312. display: flex;
  313. justify-content: space-between;
  314. align-items: flex-start;
  315. margin-top: 16px;
  316. .left-buttons {
  317. display: flex;
  318. gap: 12px;
  319. .el-button {
  320. height: 32px;
  321. padding: 0 16px;
  322. font-size: 14px;
  323. }
  324. }
  325. .right-summary {
  326. min-width: 200px;
  327. .summary-list {
  328. display: flex;
  329. flex-direction: column;
  330. align-items: flex-end;
  331. gap: 4px;
  332. .summary-item {
  333. display: flex;
  334. align-items: center;
  335. justify-content: flex-end;
  336. gap: 8px;
  337. text-align: right;
  338. .label {
  339. font-size: 16px;
  340. color: #606266;
  341. }
  342. .value {
  343. font-size: 20px;
  344. color: #606266;
  345. min-width: 80px;
  346. text-align: right;
  347. }
  348. &.total {
  349. margin-top: 4px;
  350. .label,
  351. .value {
  352. color: #f56c6c;
  353. font-weight: 500;
  354. }
  355. }
  356. }
  357. }
  358. }
  359. }
  360. }
  361. </style>