index.vue 13 KB

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