index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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" v-if="judgeAdmin()">
  26. <template #default="{ row, $index }">
  27. <el-form-item
  28. :prop="'data.' + $index + '.internalSellingPrice'"
  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.internalSellingPrice"
  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="对内销售价(含税)" prop="internalSellingPrice" width="160" v-else />
  45. <el-table-column label="安全库存" prop="safetyStock" width="120" />
  46. </el-table>
  47. </el-form>
  48. <el-row style="padding: 10px 0" justify="end" type="flex">
  49. <el-pagination
  50. background
  51. layout="total, sizes, prev, pager, next, jumper"
  52. :current-page="sourceList.pagination.pageNum"
  53. :page-size="sourceList.pagination.pageSize"
  54. :total="sourceList.pagination.total"
  55. @current-change="handlePageChange"
  56. @size-change="handleSizeChange" />
  57. </el-row>
  58. </el-card>
  59. </template>
  60. <script setup>
  61. import byTable from "/src/components/byTable/index";
  62. import { ElMessage } from "element-plus";
  63. const { proxy } = getCurrentInstance();
  64. const sourceList = ref({
  65. data: [],
  66. pagination: {
  67. total: 0,
  68. pageNum: 1,
  69. pageSize: 10,
  70. code: "",
  71. name: "",
  72. },
  73. });
  74. const loading = ref(false);
  75. const searchConfig = computed(() => {
  76. return [
  77. {
  78. type: "input",
  79. prop: "code",
  80. label: "BOM品号",
  81. },
  82. {
  83. type: "input",
  84. prop: "name",
  85. label: "BOM品名",
  86. },
  87. ];
  88. });
  89. const config = computed(() => {
  90. return [];
  91. });
  92. const getList = async (req, status) => {
  93. if (status) {
  94. sourceList.value.pagination = {
  95. pageNum: sourceList.value.pagination.pageNum,
  96. pageSize: sourceList.value.pagination.pageSize,
  97. };
  98. } else {
  99. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  100. }
  101. loading.value = true;
  102. proxy.post("/bomSpec/page", sourceList.value.pagination).then((res) => {
  103. sourceList.value.data = res.rows;
  104. sourceList.value.pagination.total = res.total;
  105. setTimeout(() => {
  106. loading.value = false;
  107. }, 200);
  108. });
  109. };
  110. getList();
  111. const clickReset = () => {
  112. getList("", true);
  113. };
  114. const handlePageChange = (val) => {
  115. getList({ pageNum: val });
  116. };
  117. const handleSizeChange = (val) => {
  118. getList({ pageNum: 1, pageSize: val });
  119. };
  120. const changePrice = (item) => {
  121. if (
  122. !(item.costPrice === null || item.costPrice === "") &&
  123. !(item.internalSellingPrice === null || item.internalSellingPrice === "") &&
  124. !(item.externalSellingPrice === null || item.externalSellingPrice === "")
  125. ) {
  126. proxy.post("/bomSpec/editPrice", item).then(() => {
  127. ElMessage({ message: "修改完成", type: "success" });
  128. });
  129. } else {
  130. return ElMessage("请输入所有价格");
  131. }
  132. };
  133. const judgeAdmin = () => {
  134. if (proxy.useUserStore().user.userId === "1") {
  135. return true;
  136. }
  137. return false;
  138. };
  139. </script>
  140. <style lang="scss" scoped>
  141. ::v-deep(.el-input-number .el-input__inner) {
  142. text-align: left;
  143. }
  144. ::v-deep(.cell .el-form-item) {
  145. margin-bottom: 0px !important;
  146. }
  147. </style>