index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div id="spec">
  3. <search-box-new
  4. ref="searchBox"
  5. :formData="formData"
  6. :formList="formList"
  7. @search="search"
  8. @init="init"
  9. />
  10. <table-list
  11. :tableSets="tableSet"
  12. :tableData="tableData"
  13. :navText="navText"
  14. :loading="loading"
  15. >
  16. <el-button
  17. size="medium"
  18. type="primary"
  19. slot="customize"
  20. @click="handleClick"
  21. >添加商品规格模板</el-button
  22. >
  23. <template slot="btn" slot-scope="props">
  24. <el-button type="text" @click="handleEdit(props.scope.row)"
  25. >修改</el-button
  26. >
  27. <el-button type="text" @click="handleDel(props.scope.row)"
  28. >删除</el-button
  29. >
  30. </template>
  31. </table-list>
  32. <pagination
  33. :total="total"
  34. :pageSize="formData.pageSize"
  35. :currentPage="formData.pageNum"
  36. @handleSizeChange="handleSizeChange"
  37. @handleCurrentChange="handleCurrentChange"
  38. />
  39. </div>
  40. </template>
  41. <script>
  42. import searchBoxNew from "@/components/searchBoxNew";
  43. import tableList from "@/components/tableList";
  44. import pagination from "@/components/pagination";
  45. import { getSpecList, delSpec } from "@/api/resource/good";
  46. export default {
  47. name:"Spec",
  48. data() {
  49. return {
  50. loading: false,
  51. //搜索
  52. formList: [
  53. {
  54. prop: "educationTypeId",
  55. placeholder: "教育类型",
  56. scope: "educationType",
  57. },
  58. {
  59. prop: "businessId",
  60. placeholder: "业务层次",
  61. scope: "businessLevel",
  62. edu: "educationTypeId",
  63. },
  64. {
  65. prop: "name",
  66. placeholder: "关联商品模板名称",
  67. },
  68. ],
  69. formData: {
  70. pageSize: 10,
  71. pageNum: 1,
  72. },
  73. total: 10,
  74. navText: {
  75. title: "商品规格列表",
  76. index: 0,
  77. ch: "条",
  78. num: false,
  79. changeWidth: "150px",
  80. border: true,
  81. choice: false,
  82. addHide: true,
  83. custom: false,
  84. backFatherBtn: {
  85. status: false,
  86. title: "未定义",
  87. },
  88. },
  89. // 表单
  90. tableSet: [
  91. {
  92. label: "教育类型",
  93. prop: "educationName",
  94. hidden: true,
  95. },
  96. {
  97. label: "业务层次",
  98. prop: "businessName",
  99. hidden: true,
  100. },
  101. {
  102. label: "商品规格模板名称",
  103. prop: "name",
  104. hidden: true,
  105. },
  106. {
  107. label: "商品规格数量",
  108. prop: "specNumber",
  109. hidden: true,
  110. },
  111. ],
  112. tableData: [],
  113. };
  114. },
  115. mounted() {
  116. this.search();
  117. },
  118. activated() {
  119. this.search();
  120. },
  121. methods: {
  122. search(i) {
  123. this.loading = true;
  124. getSpecList(this.formData)
  125. .then(({ rows, total }) => {
  126. this.tableData = rows;
  127. this.total = total;
  128. this.navText.index = total;
  129. })
  130. .finally(() => {
  131. this.loading = false;
  132. });
  133. },
  134. init() {
  135. this.formData = {
  136. pageSize: 10,
  137. pageNum: 1,
  138. };
  139. this.search();
  140. },
  141. handleCurrentChange(v) {
  142. this.formData.pageNum = v;
  143. this.search();
  144. },
  145. handleSizeChange(v) {
  146. this.formData.pageSize = v;
  147. this.formData.pageNum = 1;
  148. this.search();
  149. },
  150. handleEdit({ specTemplateId }) {
  151. this.$router.push({
  152. path: "specEdit",
  153. query: {
  154. id: specTemplateId,
  155. },
  156. });
  157. },
  158. handleClick(e) {
  159. this.$router.push({
  160. path: "specAdd",
  161. });
  162. },
  163. handleDel({ specTemplateId }) {
  164. this.$confirm("此操作将永久删除该规格模板, 是否继续?", "提示", {
  165. confirmButtonText: "确定",
  166. cancelButtonText: "取消",
  167. type: "warning",
  168. })
  169. .then(() => {
  170. delSpec(specTemplateId).then((res) => {
  171. this.$message({
  172. type: "success",
  173. message: "删除成功!",
  174. });
  175. this.search();
  176. });
  177. })
  178. .catch(() => {
  179. this.$message({
  180. type: "info",
  181. message: "已取消删除",
  182. });
  183. });
  184. },
  185. },
  186. components: { searchBoxNew, tableList, pagination },
  187. };
  188. </script>
  189. <style>
  190. </style>