index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div>
  3. <basic-container v-if="show" 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. :summary-method="summaryMethod"
  19. :cell-style="cellStyle"
  20. >
  21. <template slot="menuLeft">
  22. <el-button
  23. type="primary"
  24. icon="el-icon-plus"
  25. size="small"
  26. @click.stop="newAdd()"
  27. >新单</el-button
  28. >
  29. <el-button type="success" size="small" disabled>复制新单</el-button>
  30. <el-button type="info" size="small">报表</el-button>
  31. </template>
  32. <template slot-scope="{ row }" slot="storageId">
  33. <span>{{ row.storageName }}</span>
  34. </template>
  35. <template slot-scope="{ row }" slot="createUser">
  36. <span>{{ row.createUserName }}</span>
  37. </template>
  38. <template slot="businessDateSearch">
  39. <el-date-picker
  40. v-model="search.businessDate"
  41. type="daterange"
  42. start-placeholder="开始日期"
  43. end-placeholder="结束日期"
  44. format="yyyy-MM-dd"
  45. value-format="yyyy-MM-dd HH:mm:ss"
  46. :default-time="['00:00:00', '23:59:59']"
  47. >
  48. </el-date-picker>
  49. </template>
  50. <template slot="createTimeSearch">
  51. <el-date-picker
  52. v-model="search.createTime"
  53. type="daterange"
  54. start-placeholder="开始日期"
  55. end-placeholder="结束日期"
  56. format="yyyy-MM-dd"
  57. value-format="yyyy-MM-dd HH:mm:ss"
  58. :default-time="['00:00:00', '23:59:59']"
  59. >
  60. </el-date-picker>
  61. </template>
  62. <template slot="corpIdSearch">
  63. <select-component
  64. v-model="search.corpId"
  65. :configuration="configuration"
  66. ></select-component>
  67. </template>
  68. <template slot-scope="scope" slot="corpId">
  69. {{ scope.row.corpsName }}
  70. </template>
  71. <template slot-scope="scope" slot="menu">
  72. <el-button
  73. type="text"
  74. icon="el-icon-edit"
  75. size="small"
  76. @click.stop="editOpen(scope.row, 2)"
  77. >编辑
  78. </el-button>
  79. <el-button
  80. type="text"
  81. icon="el-icon-delete"
  82. size="small"
  83. @click.stop="rowDel(scope.row, scope.index)"
  84. >删除
  85. </el-button>
  86. </template>
  87. </avue-crud>
  88. </basic-container>
  89. <detail-page @goBack="goBack" :detailData="detailData" v-else></detail-page>
  90. </div>
  91. </template>
  92. <script>
  93. import option from "./config/mainList.json";
  94. import { getList, remove,gainUser } from "@/api/exportTrade/receipt";
  95. import detailPage from "./detailsPage.vue";
  96. import { micrometerFormat } from "@/util/validate";
  97. import { defaultDate } from "@/util/date";
  98. import _ from "lodash";
  99. export default {
  100. name: "customerInformation",
  101. data() {
  102. return {
  103. configuration: {
  104. multipleChoices: false,
  105. multiple: false,
  106. collapseTags: false,
  107. placeholder: "请点击右边按钮选择",
  108. dicData: []
  109. },
  110. search: {
  111. businessDate: defaultDate()
  112. },
  113. form: {},
  114. option: {},
  115. parentId: 0,
  116. dataList: [],
  117. page: {
  118. pageSize: 10,
  119. currentPage: 1,
  120. total: 0
  121. },
  122. show: true,
  123. detailData: {},
  124. loading: false
  125. };
  126. },
  127. components: { detailPage },
  128. async created() {
  129. this.option = await this.getColumnData(this.getColumnName(6), option);
  130. if (this.$route.query.pageType == "Generate") {
  131. this.newAdd();
  132. }
  133. let _this = this;
  134. this.option.column.forEach(e => {
  135. if (e.prop == "exchangeRate") {
  136. e.formatter = function(row) {
  137. return _this.textFormat(
  138. Number(row.exchangeRate ? row.exchangeRate : 0) / 100,
  139. "0.00%"
  140. );
  141. };
  142. }
  143. if (e.prop == "creditAmount") {
  144. e.formatter = function(row) {
  145. return _this.textFormat(
  146. Number(row.creditAmount ? row.creditAmount : 0),
  147. "#,##0.00"
  148. );
  149. };
  150. }
  151. });
  152. gainUser().then(res => {
  153. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  154. });
  155. },
  156. activated() {
  157. //当页面已打开并无法重新渲染时,用activated重新激活keepalive组件
  158. setTimeout(() => {
  159. if (this.$route.query.pageType == "Generate" && this.show) {
  160. this.newAdd();
  161. }
  162. }, 100);
  163. },
  164. methods: {
  165. cellStyle() {
  166. return "padding:0;height:40px;";
  167. },
  168. //删除列表后面的删除按钮触发触发(row, index, done)
  169. rowDel(row, index, done) {
  170. this.$confirm("确定删除数据?", {
  171. confirmButtonText: "确定",
  172. cancelButtonText: "取消",
  173. type: "warning"
  174. }).then(() => {
  175. remove(row.id).then(res => {
  176. if (res.data.code == 200) {
  177. this.$message({
  178. type: "success",
  179. message: "删除成功!"
  180. });
  181. this.onLoad(this.page, this.search);
  182. }
  183. });
  184. });
  185. },
  186. //查看跳转页面
  187. beforeOpenPage(row, status) {
  188. this.detailData = {
  189. id: row.id,
  190. status: status
  191. };
  192. this.show = false;
  193. this.$store.commit("REC_IN_DETAIL");
  194. },
  195. editOpen(row, status) {
  196. this.detailData = {
  197. id: row.id,
  198. status: status
  199. };
  200. this.show = false;
  201. this.$store.commit("REC_IN_DETAIL");
  202. },
  203. //点击搜索按钮触发
  204. searchChange(params, done) {
  205. if (params.businessDate) {
  206. params.businessStartDate = params.businessDate[0];
  207. params.businessEndDate = params.businessDate[1];
  208. }
  209. if (params.createTime) {
  210. params.createStartTime = params.createTime[0];
  211. params.createEndTime = params.createTime[1];
  212. }
  213. delete params.businessDate;
  214. delete params.createTime;
  215. this.page.currentPage = 1;
  216. this.onLoad(this.page, params);
  217. done();
  218. },
  219. currentChange(val) {
  220. this.page.currentPage = val;
  221. },
  222. sizeChange(val) {
  223. this.page.currentPage = 1;
  224. this.page.pageSize = val;
  225. },
  226. onLoad(page, params) {
  227. if (this.search.businessDate && this.search.businessDate.length > 0) {
  228. params = {
  229. ...params,
  230. businessStartDate: this.search.businessDate[0],
  231. businessEndDate: this.search.businessDate[1]
  232. };
  233. delete params.businessDate;
  234. }
  235. this.loading = true;
  236. getList(page.currentPage, page.pageSize, params)
  237. .then(res => {
  238. this.dataList = res.data.data.records ? res.data.data.records : [];
  239. this.page.total = res.data.data.total;
  240. if (this.page.total) {
  241. this.option.height = window.innerHeight - 400;
  242. }
  243. })
  244. .finally(() => {
  245. this.loading = false;
  246. });
  247. },
  248. refreshChange() {
  249. this.onLoad(this.page, this.search);
  250. },
  251. newAdd() {
  252. this.show = false;
  253. this.$store.commit("REC_IN_DETAIL");
  254. },
  255. goBack() {
  256. this.detailData = this.$options.data().detailData;
  257. if (this.$route.query.pageType == "Generate") {
  258. this.$router.$avueRouter.closeTag();
  259. this.$router.push({
  260. path: "/exportTrade/receipt/index"
  261. });
  262. }
  263. this.show = true;
  264. this.$store.commit("REC_OUT_DETAIL");
  265. },
  266. summaryMethod({ columns, data }) {
  267. const sums = [];
  268. if (columns.length > 0) {
  269. columns.forEach((item, index) => {
  270. sums[0] = "合计";
  271. if (
  272. item.property == "totalQuantity" ||
  273. item.property == "deliveryAmount" ||
  274. item.property == "totalCost"
  275. ) {
  276. let qtySum = 0;
  277. let instoreSum = 0;
  278. let totalSum = 0;
  279. data.forEach(e => {
  280. qtySum = _.add(qtySum, Number(e.totalQuantity));
  281. instoreSum = _.add(instoreSum, Number(e.deliveryAmount));
  282. totalSum = _.add(totalSum, Number(e.totalCost));
  283. });
  284. //数量总计
  285. if (item.property == "totalQuantity") {
  286. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  287. }
  288. //入库金额总计
  289. if (item.property == "deliveryAmount") {
  290. sums[index] = micrometerFormat(instoreSum);
  291. }
  292. //金额总计
  293. if (item.property == "totalCost") {
  294. sums[index] = micrometerFormat(totalSum);
  295. }
  296. }
  297. });
  298. }
  299. return sums;
  300. },
  301. async saveColumn() {
  302. const inSave = await this.saveColumnData(
  303. this.getColumnName(6),
  304. this.option
  305. );
  306. if (inSave) {
  307. this.$message.success("保存成功");
  308. //关闭窗口
  309. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  310. }
  311. }
  312. },
  313. watch: {
  314. option: function() {
  315. this.search.businessDate = defaultDate();
  316. }
  317. }
  318. };
  319. </script>
  320. <style scoped>
  321. ::v-deep .select-component {
  322. display: flex;
  323. }
  324. .page-crad ::v-deep .basic-container__card {
  325. height: 94.2vh;
  326. }
  327. </style>