index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :searchConfig="searchConfig"
  10. highlight-current-row
  11. :action-list="[
  12. {
  13. text: '添加售价体系',
  14. action: () => clickModal(),
  15. },
  16. ]"
  17. @get-list="getList"
  18. @clickReset="clickReset">
  19. </byTable>
  20. </el-card>
  21. <el-dialog :title="modalType == 'add' ? '添加售价体系' : '编辑售价体系'" v-if="openDialog" v-model="openDialog" width="600">
  22. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit"> </byForm>
  23. <template #footer>
  24. <el-button @click="openDialog = false" size="large">取 消</el-button>
  25. <el-button type="primary" @click="submitForm()" :disabled="btnDisabled" size="large">确 定</el-button>
  26. </template>
  27. </el-dialog>
  28. <el-dialog title="售价配置" v-if="openDisposition" v-model="openDisposition" width="96%">
  29. <SelectBOM :selectStatus="true" :priceSystemId="priceSystemId"></SelectBOM>
  30. <template #footer>
  31. <el-button @click="openDisposition = false" size="large">关 闭</el-button>
  32. </template>
  33. </el-dialog>
  34. </div>
  35. </template>
  36. <script setup>
  37. import byTable from "@/components/byTable/index";
  38. import byForm from "@/components/byForm/index";
  39. import { ElMessage, ElMessageBox } from "element-plus";
  40. import SelectBOM from "@/views/group/BOM/management/index";
  41. const { proxy } = getCurrentInstance();
  42. const sourceList = ref({
  43. data: [],
  44. pagination: {
  45. total: 0,
  46. pageNum: 1,
  47. pageSize: 10,
  48. name: "",
  49. },
  50. });
  51. const loading = ref(false);
  52. const searchConfig = computed(() => {
  53. return [
  54. {
  55. type: "input",
  56. prop: "name",
  57. label: "售价体系",
  58. },
  59. ];
  60. });
  61. const config = computed(() => {
  62. return [
  63. {
  64. attrs: {
  65. label: "售价体系",
  66. prop: "name",
  67. width: 180,
  68. },
  69. },
  70. {
  71. attrs: {
  72. label: "备注",
  73. prop: "name",
  74. "min-width": 240,
  75. },
  76. },
  77. {
  78. attrs: {
  79. label: "操作",
  80. width: 180,
  81. align: "center",
  82. fixed: "right",
  83. },
  84. renderHTML(row) {
  85. return [
  86. {
  87. attrs: {
  88. label: "售价配置",
  89. type: "primary",
  90. text: true,
  91. },
  92. el: "button",
  93. click() {
  94. clickDisposition(row);
  95. },
  96. },
  97. {
  98. attrs: {
  99. label: "编辑",
  100. type: "primary",
  101. text: true,
  102. },
  103. el: "button",
  104. click() {
  105. clickUpdate(row);
  106. },
  107. },
  108. {
  109. attrs: {
  110. label: "删除",
  111. type: "primary",
  112. text: true,
  113. },
  114. el: "button",
  115. click() {
  116. clickDelete(row);
  117. },
  118. },
  119. ];
  120. },
  121. },
  122. ];
  123. });
  124. const getList = async (req, status) => {
  125. if (status) {
  126. sourceList.value.pagination = {
  127. pageNum: sourceList.value.pagination.pageNum,
  128. pageSize: sourceList.value.pagination.pageSize,
  129. };
  130. } else {
  131. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  132. }
  133. loading.value = true;
  134. proxy.post("/priceSystem/page", sourceList.value.pagination).then((res) => {
  135. sourceList.value.data = res.rows;
  136. sourceList.value.pagination.total = res.total;
  137. setTimeout(() => {
  138. loading.value = false;
  139. }, 200);
  140. });
  141. };
  142. getList();
  143. const clickReset = () => {
  144. getList("", true);
  145. };
  146. const modalType = ref("add");
  147. const openDialog = ref(false);
  148. const submit = ref(null);
  149. const formOption = reactive({
  150. inline: true,
  151. labelWidth: "100px",
  152. itemWidth: 100,
  153. rules: [],
  154. labelPosition: "right",
  155. });
  156. const formData = reactive({
  157. data: {},
  158. });
  159. const formConfig = computed(() => {
  160. return [
  161. {
  162. type: "input",
  163. prop: "name",
  164. label: "售价体系",
  165. itemType: "text",
  166. },
  167. {
  168. type: "input",
  169. prop: "remark",
  170. label: "备注",
  171. itemType: "textarea",
  172. },
  173. ];
  174. });
  175. const rules = ref({
  176. name: [{ required: true, message: "请输入售价体系", trigger: "blur" }],
  177. });
  178. const btnDisabled = ref(false);
  179. const clickModal = () => {
  180. modalType.value = "add";
  181. formData.data = {};
  182. btnDisabled.value = false;
  183. openDialog.value = true;
  184. };
  185. const submitForm = () => {
  186. submit.value.handleSubmit(() => {
  187. btnDisabled.value = true;
  188. proxy.post("/priceSystem/" + modalType.value, formData.data).then(
  189. () => {
  190. ElMessage({
  191. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  192. type: "success",
  193. });
  194. openDialog.value = false;
  195. btnDisabled.value = false;
  196. getList();
  197. },
  198. (err) => {
  199. console.log(err);
  200. btnDisabled.value = false;
  201. }
  202. );
  203. });
  204. };
  205. const openDisposition = ref(false);
  206. const priceSystemId = ref("");
  207. const clickDisposition = (row) => {
  208. priceSystemId.value = row.id;
  209. openDisposition.value = true;
  210. };
  211. const clickUpdate = (row) => {
  212. modalType.value = "edit";
  213. formData.data = row;
  214. btnDisabled.value = false;
  215. openDialog.value = true;
  216. };
  217. const clickDelete = (row) => {
  218. ElMessageBox.confirm("你是否确认此操作", "提示", {
  219. confirmButtonText: "确定",
  220. cancelButtonText: "取消",
  221. type: "warning",
  222. }).then(() => {
  223. proxy.post("/priceSystem/delete", { id: row.id }).then(() => {
  224. ElMessage({ message: "删除成功", type: "success" });
  225. getList();
  226. });
  227. });
  228. };
  229. </script>
  230. <style lang="scss" scoped>
  231. :deep(.el-dialog) {
  232. margin-top: 10px !important;
  233. margin-bottom: 10px !important;
  234. }
  235. </style>