index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <div>
  3. <basic-container class="page-crad">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. v-model="form"
  9. :page.sync="page"
  10. :search.sync="search"
  11. @search-change="searchChange"
  12. @current-change="currentChange"
  13. @size-change="sizeChange"
  14. @refresh-change="refreshChange"
  15. @on-load="onLoad"
  16. :table-loading="loading"
  17. @saveColumn="saveColumn"
  18. :cell-style="cellStyle"
  19. :summary-method="summaryMethod"
  20. >
  21. <template slot="menuLeft">
  22. <el-button
  23. type="primary"
  24. icon="el-icon-plus"
  25. size="small"
  26. @click.stop="excelBox = !excelBox"
  27. >导入</el-button
  28. >
  29. <el-button
  30. type="success"
  31. icon="el-icon-upload2"
  32. size="small"
  33. @click="derivation()"
  34. >下载模板
  35. </el-button>
  36. <el-button type="info" size="small">报表</el-button>
  37. </template>
  38. <template slot="cnameSearch">
  39. <goods-select
  40. v-model="search.cname"
  41. :configuration="goodsConfiguration"
  42. />
  43. </template>
  44. <template slot="priorityReferrer" slot-scope="{ row }">
  45. <el-checkbox
  46. :disabled="!row.$cellEdit"
  47. v-model="row.priorityReferrer"
  48. :true-label="1"
  49. :false-label="0"
  50. />
  51. </template>
  52. <template slot="corpIdSearch">
  53. <select-component
  54. v-model="search.corpId"
  55. :configuration="configuration"
  56. ></select-component>
  57. </template>
  58. <template slot-scope="scope" slot="corpId">
  59. {{ scope.row.corpName }}
  60. </template>
  61. <template slot-scope="scope" slot="grossProfitRate">
  62. {{ scope.row.grossProfitRate ? scope.row.grossProfitRate : 0 }}%
  63. </template>
  64. <template slot-scope="scope" slot="status">
  65. {{ scope.row.status | orderStateFormat }}
  66. </template>
  67. <template slot-scope="scope" slot="menu">
  68. <el-button
  69. type="text"
  70. icon="el-icon-edit"
  71. size="small"
  72. @click.stop="editOpen(scope.row, 2)"
  73. >编辑
  74. </el-button>
  75. <el-button
  76. type="text"
  77. icon="el-icon-delete"
  78. size="small"
  79. @click.stop="rowDel(scope.row, scope.index)"
  80. >删除
  81. </el-button>
  82. </template>
  83. </avue-crud>
  84. <el-dialog
  85. title="导入价格"
  86. append-to-body
  87. :visible.sync="excelBox"
  88. width="555px"
  89. >
  90. <avue-form
  91. :option="excelOption"
  92. v-model="excelForm"
  93. :upload-after="uploadAfter"
  94. />
  95. </el-dialog>
  96. </basic-container>
  97. </div>
  98. </template>
  99. <script>
  100. import option from "./config/mainList.json";
  101. import { getToken } from "@/util/auth";
  102. import { getList, remove } from "@/api/maintenance/priceLibrary";
  103. import { defaultDate } from "@/util/date";
  104. import { micrometerFormat } from "@/util/validate";
  105. import { orderStateFormat } from "@/enums/order-stauts";
  106. import _ from "lodash";
  107. export default {
  108. name: "customerInformation",
  109. data() {
  110. return {
  111. excelOption: {
  112. submitBtn: false,
  113. emptyBtn: false,
  114. column: [
  115. {
  116. label: "导入数据",
  117. prop: "excelFile",
  118. type: "upload",
  119. drag: true,
  120. loadText: "导入数据中,请稍等",
  121. span: 24,
  122. propsHttp: {
  123. res: "data"
  124. },
  125. tip: "请上传 .xls,.xlsx 标准格式文件",
  126. action: "/api/blade-mocha-item/pricebank/importPrice"
  127. }
  128. ]
  129. },
  130. excelBox: false,
  131. excelForm: {},
  132. goodsConfiguration: {
  133. multipleChoices: false,
  134. multiple: false,
  135. collapseTags: false,
  136. placeholder: "请点击右边按钮选择",
  137. dicData: [],
  138. clearable: true
  139. },
  140. configuration: {
  141. multipleChoices: false,
  142. multiple: false,
  143. collapseTags: false,
  144. placeholder: "请点击右边按钮选择",
  145. dicData: [],
  146. clearable: true
  147. },
  148. search: {
  149. businesDate: defaultDate()
  150. },
  151. form: {},
  152. option: {},
  153. parentId: 0,
  154. dataList: [],
  155. page: {
  156. pageSize: 10,
  157. currentPage: 1,
  158. total: 0,
  159. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  160. },
  161. detailData: {},
  162. loading: false
  163. };
  164. },
  165. async created() {
  166. /**
  167. * 已定义全局方法,直接使用,getColumnData获取列数据,参数传值(表格名称,引入的本地JSON的数据定义的名称)
  168. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  169. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  170. */
  171. this.option = await this.getColumnData(this.getColumnName(50), option);
  172. this.getWorkDicts("billType").then(res => {
  173. this.findObject(this.option.column, "billType").dicData = res.data.data;
  174. });
  175. },
  176. filters: {
  177. orderStateFormat(val) {
  178. return orderStateFormat(val);
  179. }
  180. },
  181. methods: {
  182. cellStyle() {
  183. return "padding:0;height:40px;";
  184. },
  185. uploadAfter(res, done, loading, column) {
  186. this.excelBox = false;
  187. this.page.currentPage = 1;
  188. this.onLoad(this.page);
  189. loading();
  190. done();
  191. },
  192. derivation() {
  193. this.$confirm("是否下载模板?", "提示", {
  194. confirmButtonText: "确定",
  195. cancelButtonText: "取消",
  196. type: "warning"
  197. }).then(() => {
  198. window.open(
  199. `/api/blade-mocha-item/pricebank/exportPrice?${
  200. this.website.tokenHeader
  201. }=${getToken()}`
  202. );
  203. });
  204. },
  205. //删除列表后面的删除按钮触发触发(row, index, done)
  206. rowDel(row, index, done) {
  207. this.$confirm("确定删除数据?", {
  208. confirmButtonText: "确定",
  209. cancelButtonText: "取消",
  210. type: "warning"
  211. }).then(() => {
  212. remove(row.id).then(res => {
  213. if (res.data.code == 200) {
  214. this.$message({
  215. type: "success",
  216. message: "删除成功!"
  217. });
  218. this.onLoad(this.page, this.search);
  219. }
  220. });
  221. });
  222. },
  223. editOpen(row, status) {
  224. console.log(row, status);
  225. },
  226. //点击搜索按钮触发
  227. searchChange(params, done) {
  228. this.page.currentPage = 1;
  229. this.onLoad(this.page, params);
  230. done();
  231. },
  232. currentChange(val) {
  233. this.page.currentPage = val;
  234. },
  235. sizeChange(val) {
  236. this.page.currentPage = 1;
  237. this.page.pageSize = val;
  238. },
  239. onLoad(page, params) {
  240. params = {
  241. ...params,
  242. tradeType: "CK"
  243. };
  244. this.loading = true;
  245. getList(page.currentPage, page.pageSize, params)
  246. .then(res => {
  247. this.dataList = res.data.data.records ? res.data.data.records : [];
  248. this.page.total = res.data.data.total;
  249. if (this.page.total) {
  250. this.option.height = window.innerHeight - 300;
  251. }
  252. })
  253. .finally(() => {
  254. this.loading = false;
  255. });
  256. },
  257. summaryMethod({ columns, data }) {
  258. const sums = [];
  259. if (columns.length > 0) {
  260. columns.forEach((item, index) => {
  261. sums[0] = "合计";
  262. if (
  263. item.property == "orderQuantity" ||
  264. item.property == "amount" ||
  265. item.property == "purchaseAmount"
  266. ) {
  267. let qtySum = 0;
  268. let instoreSum = 0;
  269. let totalSum = 0;
  270. data.forEach(e => {
  271. qtySum = _.add(qtySum, Number(e.orderQuantity));
  272. instoreSum = _.add(instoreSum, Number(e.amount));
  273. totalSum = _.add(totalSum, Number(e.purchaseAmount));
  274. });
  275. //数量总计
  276. if (item.property == "orderQuantity") {
  277. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  278. }
  279. //入库金额总计
  280. if (item.property == "amount") {
  281. sums[index] = micrometerFormat(instoreSum);
  282. }
  283. //金额总计
  284. if (item.property == "purchaseAmount") {
  285. sums[index] = micrometerFormat(totalSum);
  286. }
  287. }
  288. });
  289. }
  290. return sums;
  291. },
  292. refreshChange() {
  293. this.onLoad(this.page, this.search);
  294. },
  295. async saveColumn() {
  296. /**
  297. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  298. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  299. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  300. */
  301. const inSave = await this.saveColumnData(
  302. this.getColumnName(50),
  303. this.option
  304. );
  305. if (inSave) {
  306. this.$message.success("保存成功");
  307. //关闭窗口
  308. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  309. }
  310. }
  311. }
  312. };
  313. </script>
  314. <style scoped>
  315. ::v-deep .select-component {
  316. display: flex;
  317. }
  318. .page-crad ::v-deep .basic-container__card {
  319. height: 94.2vh;
  320. }
  321. </style>