index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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. :table-loading="loading"
  12. :cell-style="cellStyle"
  13. @selection-change="selectionChange"
  14. @search-change="searchChange"
  15. @current-change="currentChange"
  16. @size-change="sizeChange"
  17. @refresh-change="refreshChange"
  18. @search-reset="searchReset"
  19. @on-load="onLoad"
  20. @search-criteria-switch="searchCriteriaSwitch"
  21. @saveColumn="saveColumn"
  22. @resetColumn="resetColumn"
  23. @expand-change="expandChange"
  24. >
  25. <template slot="orderNo" slot-scope="scope">
  26. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.orderNo }}</span>
  27. </template>
  28. <template slot="strCorpName" slot-scope="scope">
  29. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.strCorpName }}</span>
  30. </template>
  31. <template slot="createUser" slot-scope="scope">
  32. <span>{{ scope.row.createUserName }}</span>
  33. </template>
  34. <template slot="amount" slot-scope="scope">
  35. <span>{{ scope.row.amount | decimalFormat }}</span>
  36. </template>
  37. <template slot="strCorpNameSearch">
  38. <crop-select
  39. v-model="search.corpId"
  40. corpType="GYS"
  41. ></crop-select>
  42. </template>
  43. <template slot="storageNameSearch">
  44. <warehouse-select
  45. v-model="search.storageId"
  46. :configuration="configurationWarehouse"/>
  47. </template>
  48. <template slot-scope="{ row }" slot="expand">
  49. <avue-crud
  50. :data="row.itemData"
  51. :option="itemOption"
  52. :table-loading="row.itemLoading"
  53. :cell-style="cellStyle"
  54. class="itemTable"
  55. ></avue-crud>
  56. </template>
  57. <template slot="menuLeft">
  58. <el-button
  59. type="primary"
  60. icon="el-icon-plus"
  61. size="small"
  62. @click.stop="newAdd()"
  63. >创建单据</el-button>
  64. <el-button
  65. type="success"
  66. size="small"
  67. icon="el-icon-plus"
  68. @click.stop="copyDoc()"
  69. :disabled="selection.length != 1"
  70. >复制单据</el-button>
  71. </template>
  72. <template slot-scope="scope" slot="menu">
  73. <el-button
  74. type="text"
  75. icon="el-icon-delete"
  76. size="small"
  77. @click.stop="rowDel(scope.row, scope.index)"
  78. :disabled="scope.row.status == 3"
  79. >删除
  80. </el-button>
  81. </template>
  82. </avue-crud>
  83. </basic-container>
  84. <detail-page
  85. @goBack="goBack"
  86. @copyOrder="copyOrder"
  87. :detailData="detailData"
  88. v-if="!show"
  89. />
  90. </div>
  91. </template>
  92. <script>
  93. import option from './config/mainList.json';
  94. import detailPage from "./detail";
  95. import { gainUser } from "@/api/basicData/customerInquiry";
  96. import {getPurchaseList, deleteDetails, dataDetail} from "@/api/dealer/purchase";
  97. export default {
  98. name: "index",
  99. components: { detailPage },
  100. data() {
  101. return {
  102. option: {},
  103. dataList: [],
  104. form: {},
  105. page: {
  106. pageSize: 10,
  107. currentPage: 1,
  108. total: 0,
  109. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  110. },
  111. search: {},
  112. show: true,
  113. loading: false,
  114. selection: [],
  115. detailData: {},
  116. itemOption: {
  117. align: "center",
  118. header: false,
  119. menu: false,
  120. column: [
  121. {
  122. label: "产品编码",
  123. prop: "code",
  124. width: 138,
  125. overHidden: true
  126. },
  127. {
  128. label: "商品名称",
  129. prop: "cname",
  130. width: 138,
  131. overHidden: true
  132. },
  133. {
  134. label: "花纹",
  135. prop: "brandItem",
  136. width: 138,
  137. overHidden: true
  138. },
  139. {
  140. label: "负荷指数",
  141. prop: "specsOne",
  142. width: 138,
  143. overHidden: true
  144. },
  145. {
  146. label: "速度级别",
  147. prop: "specsTwo",
  148. width: 138,
  149. overHidden: true
  150. },
  151. {
  152. label: "单位",
  153. prop: "unit",
  154. width: 138,
  155. overHidden: true
  156. },
  157. {
  158. label: "数量",
  159. prop: "orderQuantity",
  160. width: 138,
  161. overHidden: true
  162. },
  163. {
  164. label: "尺寸",
  165. prop: "size",
  166. width: 138,
  167. overHidden: true
  168. },
  169. {
  170. label: "价格",
  171. prop: "price",
  172. width: 138,
  173. overHidden: true
  174. },
  175. {
  176. label: "小计",
  177. prop: "amount",
  178. width: 138,
  179. overHidden: true
  180. },
  181. ]
  182. },
  183. // 仓库配置
  184. configurationWarehouse: {
  185. multipleChoices: false,
  186. multiple: false,
  187. collapseTags: false,
  188. clearable: true,
  189. placeholder: "请点击右边按钮选择",
  190. dicData: [],
  191. },
  192. }
  193. },
  194. async created() {
  195. this.option = await this.getColumnData(this.getColumnName(81), option);
  196. gainUser().then(res => {
  197. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  198. })
  199. let i = 0;
  200. this.option.column.forEach(item => {
  201. if (item.search) i++
  202. })
  203. if (i % 3 !== 0){
  204. const num = 3 - Number(i % 3)
  205. this.option.searchMenuSpan = num * 8;
  206. this.option.searchMenuPosition = "right";
  207. }
  208. },
  209. filters: {
  210. decimalFormat(num) {
  211. return num ? Number(num).toFixed(2) : "0.00";
  212. }
  213. },
  214. methods: {
  215. searchCriteriaSwitch(type) {
  216. if (type) {
  217. this.option.height = this.option.height - 70
  218. } else {
  219. this.option.height = this.option.height + 70
  220. }
  221. this.$refs.crud.getTableHeight();
  222. },
  223. newAdd() {
  224. this.show = false;
  225. },
  226. copyDoc() {},
  227. selectionChange(list) {
  228. this.selection = list;
  229. },
  230. //删除列表后面的删除按钮触发触发(row, index, done)
  231. rowDel(row, index, done) {
  232. this.$confirm("确定删除数据?", {
  233. confirmButtonText: "确定",
  234. cancelButtonText: "取消",
  235. type: "warning"
  236. }).then(res => {
  237. return deleteDetails(row.id)
  238. }).then(() => {
  239. this.dataList.splice(row.$index, 1)
  240. this.$message({
  241. type: "success",
  242. message: "删除成功!"
  243. });
  244. this.page.currentPage = 1;
  245. this.onLoad(this.page)
  246. })
  247. },
  248. //点击搜索按钮触发
  249. searchChange(params, done) {
  250. this.onLoad(this.page, params);
  251. done();
  252. },
  253. currentChange(val) {
  254. this.page.currentPage = val;
  255. },
  256. sizeChange(val) {
  257. this.page.currentPage = 1;
  258. this.page.pageSize = val;
  259. },
  260. refreshChange() {
  261. this.onLoad(this.page, this.search);
  262. },
  263. searchReset() {
  264. this.onLoad(this.page, this.search);
  265. },
  266. cellStyle() {
  267. return "padding:0;height:40px;";
  268. },
  269. onLoad(page, params) {
  270. // 重置掉展开
  271. this.dataList.forEach(item => {
  272. this.$refs.crud.toggleRowExpansion(item, false)
  273. })
  274. let queryParams = Object.assign({}, params, {
  275. size: page.pageSize,
  276. current: page.currentPage,
  277. })
  278. if (queryParams.businesDate && queryParams.businesDate.length > 0) {
  279. queryParams = {
  280. ...queryParams,
  281. businesStartDate: queryParams.businesDate[0],
  282. businesEndDate: queryParams.businesDate[1],
  283. }
  284. }
  285. delete queryParams.businesDate;
  286. this.loading = true;
  287. getPurchaseList(queryParams).then(res => {
  288. res.data.data.records.forEach(e => {
  289. e.itemLoading = false;
  290. e.itemData = [];
  291. });
  292. this.dataList = res.data.data.records;
  293. this.page.total = res.data.data.total;
  294. this.option.height = window.innerHeight - 240;
  295. this.$nextTick(() => {
  296. this.$refs.crud.doLayout()
  297. })
  298. }).finally(() => {
  299. this.loading = false;
  300. })
  301. },
  302. async saveColumn() {
  303. const inSave = await this.saveColumnData(
  304. this.getColumnName(81),
  305. this.option
  306. );
  307. if (inSave) {
  308. this.$message.success("保存成功");
  309. //关闭窗口
  310. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  311. this.$nextTick(() => {
  312. this.$refs.crud.doLayout()
  313. })
  314. }
  315. },
  316. async resetColumn() {
  317. this.option = option;
  318. const inSave = await this.delColumnData(this.getColumnName(81), option);
  319. if (inSave) {
  320. this.$nextTick(() => {
  321. this.$refs.crud.doLayout()
  322. })
  323. this.$message.success("重置成功");
  324. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  325. }
  326. },
  327. goBack() {
  328. if (this.$route.query.id) {
  329. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  330. this.$router.push({
  331. path: "/dealer/sales/index"
  332. });
  333. }
  334. this.detailData = this.$options.data().detailData;
  335. this.show = true;
  336. this.onLoad(this.page, this.search);
  337. },
  338. copyOrder(id) {
  339. this.show = true;
  340. this.detailData = {
  341. id: id,
  342. status: "copy"
  343. };
  344. this.$nextTick(() => {
  345. this.show = false;
  346. });
  347. },
  348. beforeOpenPage(row, index) {
  349. this.show = false;
  350. this.detailData = {
  351. id: row.id,
  352. query: true, // 表示只是查询
  353. };
  354. },
  355. expandChange(row) {
  356. if (this.dataList[row.$index].itemLoading == false) {
  357. this.dataList[row.$index].itemLoading = true;
  358. dataDetail(row.id)
  359. .then(res => {
  360. this.dataList[row.$index].itemData = res.data.data.orderItemsList? res.data.data.orderItemsList: [];
  361. })
  362. .finally(() => {
  363. this.dataList[row.$index].itemLoading = false;
  364. });
  365. }
  366. },
  367. },
  368. }
  369. </script>
  370. <style scoped>
  371. ::v-deep .select-component {
  372. display: flex;
  373. }
  374. .page-crad ::v-deep .basic-container__card {
  375. height: 94.2vh;
  376. }
  377. ::v-deep .el-table__expanded-cell[class*="cell"] {
  378. padding: 0px;
  379. }
  380. </style>