index.vue 11 KB

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