index.vue 9.9 KB

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