supplier.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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="tpId"
  12. ref="tableList"
  13. :tableSets="tableSet"
  14. :tableData="tableData"
  15. :navText="navText"
  16. @sortChange="sortChange"
  17. :loading="loading"
  18. >
  19. <template slot="customize">
  20. <el-button type="primary" @click="handelClick(0)"> 新增 </el-button>
  21. <el-button @click="batchDel" type="warning"> 批量删除 </el-button>
  22. </template>
  23. <template slot="status" slot-scope="props">
  24. <el-checkbox
  25. :true-label="1"
  26. :false-label="0"
  27. @change="(val) => changeStatus(props.scope.row, val)"
  28. v-model="props.scope.row.defaultStatus"
  29. >
  30. </el-checkbox>
  31. </template>
  32. <template slot="btn" slot-scope="props">
  33. <el-button type="text" @click="handelClick(2, props.scope.row.tpId)"
  34. >复制</el-button
  35. >
  36. <el-button type="text" @click="handelClick(1, props.scope.row.tpId)"
  37. >修改</el-button
  38. >
  39. <el-button
  40. style="color: #ffba00"
  41. type="text"
  42. @click="handelDel(props.scope.row.tpId)"
  43. >删除</el-button
  44. >
  45. </template>
  46. </table-list>
  47. <pagination
  48. :total="total"
  49. :pageSize.sync="formData.pageSize"
  50. :currentPage.sync="formData.pageNum"
  51. @search="search"
  52. />
  53. <dislog-set
  54. :dialogVisible.sync="dialogVisible"
  55. :tpId="tpId"
  56. :type="type"
  57. :tenantList="institutionList"
  58. @search="search"
  59. ></dislog-set>
  60. </div>
  61. </template>
  62. <script>
  63. import dislogSet from "./dislogSupplierSet.vue";
  64. import searchBoxNew from "@/components/searchBoxNew";
  65. import tableList from "@/components/tableList";
  66. import pagination from "@/components/pagination";
  67. import {
  68. supplierList,
  69. institutionList,
  70. instDefaultStatus,
  71. editInstCost,
  72. supplierBatchCost,
  73. } from "@/api/financed/index";
  74. export default {
  75. name: "Cost",
  76. components: { searchBoxNew, tableList, pagination, dislogSet },
  77. data() {
  78. return {
  79. loading: false,
  80. navText: {
  81. title: "供应成本",
  82. index: 0,
  83. ch: "条",
  84. num: true,
  85. choice: true,
  86. addHide: true,
  87. openCheckMore: true,
  88. custom: false,
  89. changeWidth: "300px",
  90. },
  91. formList: [
  92. {
  93. prop: "instId",
  94. placeholder: "关联供应商",
  95. scope: "select",
  96. selectLabel: "instName",
  97. selectValue: "instId",
  98. options: [],
  99. },
  100. {
  101. prop: "tpName",
  102. placeholder: "模板搜索",
  103. },
  104. ],
  105. formData: {},
  106. tableSet: [
  107. {
  108. label: "模板名称",
  109. prop: "tpName",
  110. hidden: true,
  111. },
  112. {
  113. label: "关联供应商",
  114. prop: "instName",
  115. hidden: true,
  116. // sort: "custom",
  117. },
  118. {
  119. label: "默认",
  120. prop: "startTime",
  121. hidden: true,
  122. scope: "slot",
  123. slotName: "status",
  124. },
  125. ],
  126. tableData: [],
  127. total: 0,
  128. dialogVisible: !true,
  129. tpId: "",
  130. type: 0,
  131. institutionList: [],
  132. };
  133. },
  134. created() {
  135. this.search(2);
  136. this.getInstitutionList();
  137. },
  138. methods: {
  139. getInstitutionList() {
  140. institutionList({
  141. pageSize: 999,
  142. pageNum: 1,
  143. status:1
  144. }).then((res) => {
  145. this.institutionList = res.rows;
  146. this.formList[0].options = this.institutionList;
  147. });
  148. },
  149. handelClick(type, tpId) {
  150. this.dialogVisible = true;
  151. this.type = type;
  152. this.tpId = tpId;
  153. },
  154. changeStatus({ tpId, instId }, defaultStatus) {
  155. instDefaultStatus({ tpId, instId, defaultStatus }).then((res) => {
  156. this.$message.success("状态修改成功");
  157. this.search();
  158. });
  159. },
  160. batchDel() {
  161. const ids = this.$refs.tableList.allCheckData.map((item) => item.tpId);
  162. if (!ids.length) {
  163. return this.$message.warning("请先勾选模板");
  164. }
  165. this.handelDel(ids, 1);
  166. },
  167. handelDel(tpId, type = 0) {
  168. this.$confirm(
  169. `此操作将删除${type ? "批量" : "该"}模板, 是否继续?`,
  170. "提示",
  171. {
  172. confirmButtonText: "确定",
  173. cancelButtonText: "取消",
  174. type: "warning",
  175. }
  176. )
  177. .then(() => {
  178. if (type) {
  179. supplierBatchCost({ ids: tpId }).then((res) => {
  180. this.$message.success("删除成功");
  181. this.$refs.tableList.clearMoreActive();
  182. this.search();
  183. });
  184. } else {
  185. editInstCost({ tpId, status: -1 }).then((res) => {
  186. this.$message.success("删除成功");
  187. this.$refs.tableList.clearMoreActive();
  188. this.search();
  189. });
  190. }
  191. })
  192. .catch(() => {
  193. this.$message({
  194. type: "info",
  195. message: "已取消删除",
  196. });
  197. });
  198. },
  199. search(v) {
  200. this.loading = true;
  201. if (v === 2) {
  202. this.formData = {
  203. pageSize: 10,
  204. pageNum: 1,
  205. statusList: "0,1",
  206. tenantSort: undefined,
  207. };
  208. this.$nextTick(() => {
  209. this.$refs.tableList.clearMoreActive();
  210. });
  211. }
  212. supplierList(this.formData)
  213. .then((res) => {
  214. this.tableData = res.rows;
  215. this.total = res.total;
  216. this.navText.index = res.total;
  217. })
  218. .finally(() => {
  219. this.loading = false;
  220. });
  221. },
  222. sortChange(data) {
  223. this.formData.tenantSort = data.order
  224. ? data.order == "ascending"
  225. ? 1
  226. : 0
  227. : undefined;
  228. this.formData.pageNum = 1;
  229. this.search();
  230. },
  231. init() {
  232. this.search(2);
  233. },
  234. },
  235. };
  236. </script>
  237. <style lang="scss" scoped></style>