index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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="dateValiditySearch">
  59. <el-date-picker
  60. v-model="search.dateValidity"
  61. type="daterange"
  62. start-placeholder="开始日期"
  63. end-placeholder="结束日期"
  64. format="yyyy-MM-dd"
  65. value-format="yyyy-MM-dd HH:mm:ss"
  66. :default-time="['00:00:00', '23:59:59']"
  67. >
  68. </el-date-picker>
  69. </template>
  70. <template slot-scope="scope" slot="corpId">
  71. {{ scope.row.corpName }}
  72. </template>
  73. <template slot-scope="scope" slot="grossProfitRate">
  74. {{ scope.row.grossProfitRate ? scope.row.grossProfitRate : 0 }}%
  75. </template>
  76. <template slot-scope="scope" slot="status">
  77. {{ scope.row.status | orderStateFormat }}
  78. </template>
  79. <template slot-scope="scope" slot="taxRate">
  80. {{ scope.row.taxRate | taxRateFormat }}
  81. </template>
  82. <template slot-scope="scope" slot="menu">
  83. <el-button
  84. type="text"
  85. icon="el-icon-edit"
  86. size="small"
  87. @click.stop="editOpen(scope.row, 2)"
  88. >修改
  89. </el-button>
  90. <el-button
  91. type="text"
  92. icon="el-icon-delete"
  93. size="small"
  94. @click.stop="rowDel(scope.row, scope.index)"
  95. >删除
  96. </el-button>
  97. </template>
  98. </avue-crud>
  99. <el-dialog
  100. title="导入价格"
  101. append-to-body
  102. :visible.sync="excelBox"
  103. width="555px"
  104. >
  105. <avue-form
  106. :option="excelOption"
  107. v-model="excelForm"
  108. :upload-after="uploadAfter"
  109. class="excelUpload"
  110. />
  111. </el-dialog>
  112. </basic-container>
  113. </div>
  114. </template>
  115. <script>
  116. import option from "./config/mainList.json";
  117. import { getToken } from "@/util/auth";
  118. import { getList, remove, getGoodstype } from "@/api/maintenance/priceLibrary";
  119. import { defaultDate } from "@/util/date";
  120. import { micrometerFormat } from "@/util/validate";
  121. import { orderStateFormat } from "@/enums/order-stauts";
  122. import { taxRateFormat } from "@/enums/tax-rate";
  123. import _ from "lodash";
  124. export default {
  125. name: "customerInformation",
  126. data() {
  127. return {
  128. excelOption: {
  129. submitBtn: false,
  130. emptyBtn: false,
  131. column: [
  132. {
  133. label: "导入数据",
  134. prop: "excelFile",
  135. type: "upload",
  136. drag: true,
  137. loadText: "导入数据中,请稍等",
  138. span: 24,
  139. propsHttp: {
  140. res: "data"
  141. },
  142. tip: "请上传 .xls,.xlsx 标准格式文件",
  143. action: "/api/blade-mocha-item/pricebank/importPrice"
  144. }
  145. ]
  146. },
  147. excelBox: false,
  148. excelForm: {},
  149. goodsConfiguration: {
  150. multipleChoices: false,
  151. multiple: false,
  152. collapseTags: false,
  153. placeholder: "请点击右边按钮选择",
  154. dicData: [],
  155. clearable: true
  156. },
  157. configuration: {
  158. multipleChoices: false,
  159. multiple: false,
  160. collapseTags: false,
  161. placeholder: "请点击右边按钮选择",
  162. dicData: [],
  163. clearable: true
  164. },
  165. search: {},
  166. form: {},
  167. option: {},
  168. parentId: 0,
  169. dataList: [],
  170. page: {
  171. pageSize: 10,
  172. currentPage: 1,
  173. total: 0,
  174. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  175. },
  176. detailData: {},
  177. loading: false
  178. };
  179. },
  180. async created() {
  181. /**
  182. * 已定义全局方法,直接使用,getColumnData获取列数据,参数传值(表格名称,引入的本地JSON的数据定义的名称)
  183. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  184. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  185. */
  186. this.option = await this.getColumnData(this.getColumnName(50), option);
  187. this.getWorkDicts("billType").then(res => {
  188. this.findObject(this.option.column, "billType").dicData = res.data.data;
  189. });
  190. getGoodstype(1, 500).then(res => {
  191. this.findObject(this.option.column, "goodsTypeName").dicData =
  192. res.data.data.records;
  193. });
  194. },
  195. filters: {
  196. orderStateFormat(val) {
  197. return orderStateFormat(val);
  198. },
  199. taxRateFormat(val) {
  200. return taxRateFormat(val);
  201. }
  202. },
  203. methods: {
  204. cellStyle() {
  205. return "padding:0;height:40px;";
  206. },
  207. uploadAfter(res, done, loading, column) {
  208. if (res != "导入成功") {
  209. this.$message.error(res);
  210. }
  211. this.excelBox = false;
  212. this.page.currentPage = 1;
  213. this.onLoad(this.page);
  214. loading();
  215. done();
  216. },
  217. derivation() {
  218. this.$confirm("是否下载模板?", "提示", {
  219. confirmButtonText: "确定",
  220. cancelButtonText: "取消",
  221. type: "warning"
  222. }).then(() => {
  223. window.open(
  224. `/api/blade-mocha-item/pricebank/exportPrice?${
  225. this.website.tokenHeader
  226. }=${getToken()}`
  227. );
  228. });
  229. },
  230. //删除列表后面的删除按钮触发触发(row, index, done)
  231. rowDel(row, index, done) {
  232. this.$confirm("确定删除数据?", {
  233. confirmButtonText: "确定",
  234. cancelButtonText: "取消",
  235. type: "warning"
  236. }).then(() => {
  237. remove(row.id).then(res => {
  238. if (res.data.code == 200) {
  239. this.$message({
  240. type: "success",
  241. message: "删除成功!"
  242. });
  243. this.onLoad(this.page, this.search);
  244. }
  245. });
  246. });
  247. },
  248. editOpen(row, status) {
  249. this.$message.warning("暂不支持修改");
  250. console.log(row, status);
  251. },
  252. //点击搜索按钮触发
  253. searchChange(params, done) {
  254. if (params.dateValidity) {
  255. params.dateValidityStart = params.dateValidity[0];
  256. params.dateValidityEnd = params.dateValidity[1];
  257. }
  258. delete params.dateValidity;
  259. this.onLoad(this.page, params);
  260. done();
  261. },
  262. currentChange(val) {
  263. this.page.currentPage = val;
  264. },
  265. sizeChange(val) {
  266. this.page.currentPage = 1;
  267. this.page.pageSize = val;
  268. },
  269. onLoad(page, params) {
  270. params = {
  271. ...params,
  272. tradeType: "CK"
  273. };
  274. this.loading = true;
  275. getList(page.currentPage, page.pageSize, params)
  276. .then(res => {
  277. this.dataList = res.data.data.records ? res.data.data.records : [];
  278. this.page.total = res.data.data.total;
  279. if (this.page.total) {
  280. this.option.height = window.innerHeight - 300;
  281. }
  282. })
  283. .finally(() => {
  284. this.loading = false;
  285. });
  286. },
  287. summaryMethod({ columns, data }) {
  288. const sums = [];
  289. if (columns.length > 0) {
  290. columns.forEach((item, index) => {
  291. sums[0] = "合计";
  292. if (item.property == "price" || item.property == "purchaseAmount") {
  293. let priceSum = 0;
  294. let amountSum = 0;
  295. data.forEach(e => {
  296. priceSum = _.add(priceSum, Number(e.price));
  297. amountSum = _.add(amountSum, Number(e.purchaseAmount));
  298. });
  299. //最新价格
  300. if (item.property == "price") {
  301. sums[index] = micrometerFormat(priceSum);
  302. }
  303. //采购价格
  304. if (item.property == "purchaseAmount") {
  305. sums[index] = micrometerFormat(amountSum);
  306. }
  307. }
  308. });
  309. }
  310. return sums;
  311. },
  312. refreshChange() {
  313. this.onLoad(this.page, this.search);
  314. },
  315. async saveColumn() {
  316. const inSave = await this.saveColumnData(
  317. this.getColumnName(50),
  318. this.option
  319. );
  320. if (inSave) {
  321. this.$message.success("保存成功");
  322. //关闭窗口
  323. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  324. }
  325. }
  326. }
  327. };
  328. </script>
  329. <style scoped>
  330. ::v-deep .select-component {
  331. display: flex;
  332. }
  333. .page-crad ::v-deep .basic-container__card {
  334. height: 94.2vh;
  335. }
  336. .excelUpload ::v-deep .el-upload-list {
  337. display: none;
  338. }
  339. </style>