index.vue 9.9 KB

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