index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <el-card class="box-card">
  3. <byTable
  4. :hideTable="true"
  5. :hidePagination="true"
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. :searchConfig="searchConfig"
  11. highlight-current-row
  12. @get-list="getList"
  13. @clickReset="clickReset">
  14. </byTable>
  15. <el-form :model="sourceList" ref="quotedPrice">
  16. <el-table :data="sourceList.data" :row-style="{ height: '35px' }" header-row-class-name="tableHeader" v-loading="loading">
  17. <el-table-column label="BOM品号" prop="code" width="160" />
  18. <el-table-column label="BOM品名" prop="name" min-width="220" />
  19. <el-table-column label="颜色" prop="colour" width="160" />
  20. <el-table-column label="尺寸(长宽高,cm)" width="200">
  21. <template #default="{ row }">
  22. <div>{{ row.length }} * {{ row.width }} * {{ row.height }}</div>
  23. </template>
  24. </el-table-column>
  25. <el-table-column label="成本价" width="160">
  26. <template #default="{ row, $index }">
  27. <el-form-item
  28. :prop="'data.' + $index + '.costPrice'"
  29. :rules="[{ required: true, message: '请输入成本价', trigger: 'blur' }]"
  30. :inline-message="true"
  31. style="width: 100%"
  32. @change="changePrice(row)">
  33. <el-input-number
  34. onmousewheel="return false;"
  35. v-model="row.costPrice"
  36. placeholder="成本价"
  37. style="width: 100%"
  38. :controls="false"
  39. :min="0"
  40. :precision="2" />
  41. </el-form-item>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="对内销售价(含税)" width="160">
  45. <template #default="{ row, $index }">
  46. <el-form-item
  47. :prop="'data.' + $index + '.internalSellingPrice'"
  48. :rules="[{ required: true, message: '请输入成本价', trigger: 'blur' }]"
  49. :inline-message="true"
  50. style="width: 100%"
  51. @change="changePrice(row)">
  52. <el-input-number
  53. onmousewheel="return false;"
  54. v-model="row.internalSellingPrice"
  55. placeholder="成本价"
  56. style="width: 100%"
  57. :controls="false"
  58. :min="0"
  59. :precision="2" />
  60. </el-form-item>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="对外销售价(含税)" width="160">
  64. <template #default="{ row, $index }">
  65. <el-form-item
  66. :prop="'data.' + $index + '.externalSellingPrice'"
  67. :rules="[{ required: true, message: '请输入成本价', trigger: 'blur' }]"
  68. :inline-message="true"
  69. style="width: 100%"
  70. @change="changePrice(row)">
  71. <el-input-number
  72. onmousewheel="return false;"
  73. v-model="row.externalSellingPrice"
  74. placeholder="成本价"
  75. style="width: 100%"
  76. :controls="false"
  77. :min="0"
  78. :precision="2" />
  79. </el-form-item>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="安全库存" prop="safetyStock" width="120" />
  83. </el-table>
  84. </el-form>
  85. <el-row style="padding: 10px 0" justify="end" type="flex">
  86. <el-pagination
  87. background
  88. layout="total, sizes, prev, pager, next, jumper"
  89. :current-page="sourceList.pagination.pageNum"
  90. :page-size="sourceList.pagination.pageSize"
  91. :total="sourceList.pagination.total"
  92. @current-change="handlePageChange"
  93. @size-change="handleSizeChange" />
  94. </el-row>
  95. </el-card>
  96. </template>
  97. <script setup>
  98. import byTable from "/src/components/byTable/index";
  99. import { ElMessage } from "element-plus";
  100. const { proxy } = getCurrentInstance();
  101. const sourceList = ref({
  102. data: [],
  103. pagination: {
  104. total: 0,
  105. pageNum: 1,
  106. pageSize: 10,
  107. code: "",
  108. name: "",
  109. },
  110. });
  111. const loading = ref(false);
  112. const searchConfig = computed(() => {
  113. return [
  114. {
  115. type: "input",
  116. prop: "code",
  117. label: "BOM品号",
  118. },
  119. {
  120. type: "input",
  121. prop: "name",
  122. label: "BOM品名",
  123. },
  124. ];
  125. });
  126. const config = computed(() => {
  127. return [];
  128. });
  129. const getList = async (req, status) => {
  130. if (status) {
  131. sourceList.value.pagination = {
  132. pageNum: sourceList.value.pagination.pageNum,
  133. pageSize: sourceList.value.pagination.pageSize,
  134. };
  135. } else {
  136. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  137. }
  138. loading.value = true;
  139. proxy.post("/bomSpec/page", sourceList.value.pagination).then((res) => {
  140. sourceList.value.data = res.rows;
  141. sourceList.value.pagination.total = res.total;
  142. setTimeout(() => {
  143. loading.value = false;
  144. }, 200);
  145. });
  146. };
  147. getList();
  148. const clickReset = () => {
  149. getList("", true);
  150. };
  151. const handlePageChange = (val) => {
  152. getList({ pageNum: val });
  153. };
  154. const handleSizeChange = (val) => {
  155. getList({ pageNum: 1, pageSize: val });
  156. };
  157. const changePrice = (item) => {
  158. if (
  159. !(item.costPrice === null || item.costPrice === "") &&
  160. !(item.internalSellingPrice === null || item.internalSellingPrice === "") &&
  161. !(item.externalSellingPrice === null || item.externalSellingPrice === "")
  162. ) {
  163. proxy.post("/bomSpec/editPrice", item).then(() => {
  164. ElMessage({ message: "修改完成", type: "success" });
  165. });
  166. } else {
  167. return ElMessage("请输入所有价格");
  168. }
  169. };
  170. </script>
  171. <style lang="scss" scoped>
  172. ::v-deep(.el-input-number .el-input__inner) {
  173. text-align: left;
  174. }
  175. ::v-deep(.cell .el-form-item) {
  176. margin-bottom: 0px !important;
  177. }
  178. </style>