index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div id="ActivityList">
  3. <search-box-new
  4. ref="searchBox"
  5. :formData="formData"
  6. :formList="formList"
  7. @search="search"
  8. @init="init"
  9. />
  10. <table-list
  11. rowKey="id"
  12. ref="tableList"
  13. :tableSets="tableSet"
  14. :tableData="tableData"
  15. :navText="navText"
  16. :loading="loading"
  17. >
  18. <template slot="customize">
  19. <el-button type="primary" @click="handelClick(0)"> 新增 </el-button>
  20. <el-button @click="batchDel" type="warning"> 批量删除 </el-button>
  21. </template>
  22. <template slot="pcost" slot-scope="props">
  23. <div>税收:40%</div>
  24. <div>税收:40%</div>
  25. </template>
  26. <template slot="fcost" slot-scope="props">
  27. <div>税收:40</div>
  28. <div>税收:40</div>
  29. </template>
  30. <template slot="status" slot-scope="props">
  31. <el-checkbox
  32. @change="changeStatus"
  33. :checked="!!props.scope.row.status"
  34. ></el-checkbox>
  35. </template>
  36. <template slot="btn" slot-scope="props">
  37. <el-button type="text" @click="handelClick(2, props.scope.row)"
  38. >复制</el-button
  39. >
  40. <el-button type="text" @click="handelClick(1, props.scope.row)"
  41. >修改</el-button
  42. >
  43. <el-button type="text" @click="handelDel(props.scope.row.id)"
  44. >删除</el-button
  45. >
  46. </template>
  47. </table-list>
  48. <pagination
  49. :total="total"
  50. :pageSize.sync="formData.pageSize"
  51. :currentPage.sync="formData.pageNum"
  52. @search="search"
  53. />
  54. <dislog-set
  55. :dialogVisible.sync="dialogVisible"
  56. :id="id"
  57. :type="type"
  58. @search="search"
  59. ></dislog-set>
  60. </div>
  61. </template>
  62. <script>
  63. import dislogSet from "./dislogSet.vue";
  64. import searchBoxNew from "@/components/searchBoxNew";
  65. import tableList from "@/components/tableList";
  66. import pagination from "@/components/pagination";
  67. export default {
  68. name: "cost",
  69. components: { searchBoxNew, tableList, pagination, dislogSet },
  70. data() {
  71. return {
  72. loading: false, //当前表单加载是否加载动画
  73. navText: {
  74. title: "成本模板",
  75. index: 0,
  76. ch: "条",
  77. num: true,
  78. choice: true,
  79. addHide: true,
  80. openCheckMore: true,
  81. changeWidth: "160px",
  82. custom: false,
  83. backFatherBtn: {
  84. status: false,
  85. title: "配置下单填选模板",
  86. },
  87. },
  88. //搜索
  89. formList: [
  90. {
  91. prop: "name",
  92. placeholder: "请输入模板名称",
  93. },
  94. ],
  95. formData: {
  96. pageSize: 10,
  97. pageNum: 1,
  98. },
  99. // 表单
  100. tableSet: [
  101. {
  102. label: "模板名称",
  103. prop: "name",
  104. hidden: true,
  105. },
  106. {
  107. label: "百分比成本",
  108. prop: "posterTempName",
  109. hidden: true,
  110. scope: "solt",
  111. soltName: "pcost",
  112. },
  113. {
  114. label: "固定成本成本",
  115. prop: "posterTempName1",
  116. hidden: true,
  117. scope: "solt",
  118. soltName: "fcost",
  119. },
  120. {
  121. label: "默认状态",
  122. prop: "startTime",
  123. hidden: true,
  124. scope: "solt",
  125. soltName: "status",
  126. },
  127. ],
  128. tableData: [], //表单数据
  129. total: 0, //一共多少条
  130. dialogVisible: false,
  131. id: "",
  132. type: 0,
  133. };
  134. },
  135. created() {
  136. this.search();
  137. },
  138. methods: {
  139. handelClick(type, id) {
  140. this.dialogVisible = true;
  141. this.type = type;
  142. if (type !== 0) {
  143. this.id = id;
  144. }
  145. },
  146. changeStatus(val) {
  147. console.log(val);
  148. },
  149. batchDel() {
  150. let len = this.$refs.tableList.allCheckData.length;
  151. if (!len) {
  152. return this.$message.warning("请先勾选模板");
  153. }
  154. const ids = this.$refs.tableList.allCheckData.map((item) => item.id);
  155. },
  156. handelDel(id) {
  157. this.$confirm("此操作将删除该模板, 是否继续?", "提示", {
  158. confirmButtonText: "确定",
  159. cancelButtonText: "取消",
  160. type: "warning",
  161. })
  162. .then(() => {
  163. this.$api.editUser(id).then((res) => {
  164. if (res.code === 200) {
  165. this.$message.success("删除成功");
  166. this.search();
  167. }
  168. });
  169. })
  170. .catch(() => {
  171. this.$message({
  172. type: "info",
  173. message: "已取消删除",
  174. });
  175. });
  176. },
  177. search(v) {
  178. this.loading = true;
  179. if (v === 2) {
  180. this.formData = {
  181. pageSize: 10,
  182. pageNum: 1,
  183. };
  184. }
  185. var data = JSON.parse(JSON.stringify(this.formData));
  186. // if (this.formData.classStartTime) {
  187. // data.classStartTime = parseInt(data.classStartTime / 1000);
  188. // }
  189. // if (this.formData.classEndTime) {
  190. // data.classEndTime = parseInt(data.classEndTime / 1000);
  191. // }
  192. this.$api
  193. .distributiontemplist(data)
  194. .then((res) => {
  195. this.tableData = res.rows;
  196. this.total = res.total;
  197. this.navText.index = res.total;
  198. })
  199. .finally(() => {
  200. this.loading = false;
  201. });
  202. },
  203. init() {
  204. this.search(2);
  205. },
  206. },
  207. };
  208. </script>
  209. <style lang="scss" scoped></style>