index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <template>
  2. <div>
  3. <basic-container
  4. v-show="isShow">
  5. <avue-crud :option="option"
  6. :data="dataList"
  7. ref="crud"
  8. v-model="form"
  9. :page.sync="page"
  10. @row-del="rowDel"
  11. @row-update="rowUpdate"
  12. :before-open="beforeOpen"
  13. :before-close="beforeClose"
  14. :search.sync="search"
  15. @row-save="rowSave"
  16. @saveColumn="saveColumn"
  17. @search-change="searchChange"
  18. @search-reset="searchReset"
  19. @selection-change="selectionChange"
  20. @current-change="currentChange"
  21. @size-change="sizeChange"
  22. @refresh-change="refreshChange"
  23. @on-load="onLoad"
  24. @tree-load="treeLoad"
  25. :cell-style="tableRowClassName"
  26. :table-loading="loading"
  27. @expand-change="expandChange"
  28. @resetColumn="resetColumn"
  29. >
  30. <template slot-scope="scope" slot="expand">
  31. <el-table :data="scope.row.insideList" v-loading="scope.row.loading">
  32. <el-table-column label="产品分类" prop="priceCategory" align="center" show-overflow-tooltip width="200"></el-table-column>
  33. <el-table-column label="价格类别" prop="priceType" align="center" show-overflow-tooltip width="180"></el-table-column>
  34. <el-table-column label="商品名称" prop="cname" align="center" show-overflow-tooltip width="120"></el-table-column>
  35. <el-table-column label="编码" prop="code" align="center" show-overflow-tooltip width="120"></el-table-column>
  36. <el-table-column label="规格型号" prop="typeno" align="center" show-overflow-tooltip width="120"></el-table-column>
  37. <el-table-column label="供应商" prop="corpName" align="center" show-overflow-tooltip width="120"></el-table-column>
  38. <el-table-column label="订货数量" prop="orderQuantity" align="center" show-overflow-tooltip width="180"></el-table-column>
  39. <el-table-column label="发货数量" prop="actualQuantity" align="center" show-overflow-tooltip width="200"></el-table-column>
  40. <el-table-column label="库存" prop="storageQuantity" align="center" show-overflow-tooltip width="200"></el-table-column>
  41. <el-table-column label="采购价格" prop="purchaseAmount" align="center" show-overflow-tooltip width="200"></el-table-column>
  42. <el-table-column label="最新单价" prop="price" align="center" show-overflow-tooltip width="200"></el-table-column>
  43. <el-table-column label="金额" prop="amount" align="center" show-overflow-tooltip width="200"></el-table-column>
  44. </el-table>
  45. </template>
  46. <template slot-scope="scope" slot="orderNo">
  47. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.orgOrderNo }}</span>
  48. </template>
  49. <template slot="corpIdSearch">
  50. <crop-select
  51. v-model="search.corpId"
  52. corpType="KH"
  53. ></crop-select>
  54. </template>
  55. <template slot-scope="scope" slot="corpId">
  56. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.corpsName }}</span>
  57. </template>
  58. <template slot-scope="scope" slot="createUser">
  59. {{ scope.row.createUserName }}
  60. </template>
  61. <template slot="menuLeft" slot-scope="{size}">
  62. <el-button type="success" :size="size" @click="copyOrder" :disabled="single">复制单据</el-button>
  63. <el-button type="info" :size="size" icon="el-icon-printer">报 表</el-button>
  64. </template>
  65. <template slot-scope="scope" slot="menu">
  66. <!-- <el-button-->
  67. <!-- type="text"-->
  68. <!-- icon="el-icon-view"-->
  69. <!-- size="small"-->
  70. <!-- @click.stop="beforeOpenPage(scope.row,scope.index)"-->
  71. <!-- >查看-->
  72. <!-- </el-button>-->
  73. <el-button
  74. type="text"
  75. icon="el-icon-edit"
  76. size="small"
  77. @click.stop="editOpen(scope.row,scope.index)"
  78. >编辑
  79. </el-button>
  80. <el-button
  81. type="text"
  82. icon="el-icon-delete"
  83. size="small"
  84. @click.stop="rowDel(scope.row,scope.index)"
  85. :disabled="scope.row.status > 0"
  86. >删除
  87. </el-button>
  88. </template>
  89. </avue-crud>
  90. </basic-container>
  91. <detail-page
  92. ref="detail"
  93. @goBack="goBack"
  94. :detailData="detailData"
  95. v-if="!isShow"
  96. ></detail-page>
  97. </div>
  98. </template>
  99. <script>
  100. import option from "./configuration/mainList.json";
  101. import {customerList, typeSave, deleteDetails, saveSell,detail} from "@/api/basicData/configuration"
  102. import detailPage from "./detailsPageEdit";
  103. import search from "../../../page/index/search";
  104. import { defaultDate } from "@/util/date";
  105. export default {
  106. name: "customerInformation",
  107. components: {
  108. detailPage
  109. },
  110. data() {
  111. return {
  112. loading: false,
  113. configuration: {
  114. multipleChoices: false,
  115. multiple: false,
  116. collapseTags: false,
  117. placeholder: "请点击右边按钮选择",
  118. dicData: [],
  119. clearable: true
  120. },
  121. form: {},
  122. option: {},
  123. parentId: 0,
  124. search:{},
  125. dataList: [],
  126. page: {
  127. pageSize: 10,
  128. currentPage: 1,
  129. total: 0,
  130. pageSizes: [10,50,100,200,300]
  131. },
  132. // 非单个禁用
  133. single: true,
  134. // 非多个禁用
  135. multiple: true,
  136. selection: [],
  137. isShow: true,
  138. detailData: {},
  139. }
  140. },
  141. async created() {
  142. this.search.businesDate = defaultDate(1)
  143. // this.option = option
  144. this.option = await this.getColumnData(this.getColumnName(14), option);
  145. let i = 0;
  146. this.option.column.forEach(item => {
  147. if (item.search) i++
  148. })
  149. if (i % 3 !== 0){
  150. const num = 3 - Number(i % 3)
  151. this.option.searchMenuSpan = num * 8;
  152. this.option.searchMenuPosition = "right";
  153. }
  154. this.option.column.forEach(item => {
  155. if (item.pickerOptions) {
  156. item.pickerOptions = {
  157. shortcuts: [{
  158. text: '最近一周',
  159. onClick(picker) {
  160. const end = new Date();
  161. const start = new Date();
  162. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  163. picker.$emit('pick', [start, end]);
  164. }
  165. }, {
  166. text: '最近一个月',
  167. onClick(picker) {
  168. const end = new Date();
  169. const start = new Date();
  170. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  171. picker.$emit('pick', [start, end]);
  172. }
  173. }, {
  174. text: '最近三个月',
  175. onClick(picker) {
  176. const end = new Date();
  177. const start = new Date();
  178. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  179. picker.$emit('pick', [start, end]);
  180. }
  181. }]
  182. }
  183. }
  184. })
  185. },
  186. activated() {
  187. setTimeout(() => {
  188. if (this.$route.query.id) {
  189. this.isShow = true
  190. this.beforeOpenPage({id: this.$route.query.id})
  191. }
  192. if (this.$route.query.check) {
  193. this.isShow = true
  194. // this.beforeOpenPage({id: this.$route.query.check.billId})
  195. this.detailData = {
  196. id: this.$route.query.check.billId,
  197. check: this.$route.query.check,
  198. };
  199. this.isShow = false;
  200. this.$store.commit("DOMXS_IN_DETAIL");
  201. }
  202. if (this.$route.query.params) {
  203. this.beforeOpenPage({id: this.$route.query.params})
  204. }
  205. }, 100)
  206. },
  207. methods: {
  208. tableRowClassName({row, column, rowIndex, columnIndex}) {
  209. if (row.orderStatus == '录入' && columnIndex == 19){
  210. return {
  211. background: '#eceb3c',
  212. }
  213. } else if (row.orderStatus == '成交') {
  214. return 'success-row'
  215. } else if (row.orderStatus == '已报价') {
  216. return 'quote-row'
  217. } else if (row.orderStatus == '未成交') {
  218. return 'warning-row'
  219. }
  220. return '';
  221. },
  222. //删除列表后面的删除按钮触发触发(row, index, done)
  223. rowDel(row, index, done) {
  224. this.$confirm("确定将选择数据删除?", {
  225. confirmButtonText: "确定",
  226. cancelButtonText: "取消",
  227. type: "warning"
  228. }).then(() => {
  229. return deleteDetails(row.id);
  230. }).then(() => {
  231. this.$message({
  232. type: "success",
  233. message: "操作成功!"
  234. });
  235. this.page.currentPage = 1;
  236. this.onLoad(this.page, {parentId: 0});
  237. });
  238. },
  239. //修改时的修改按钮点击触发
  240. rowUpdate(row, index, done, loading) {
  241. typeSave(row).then(() => {
  242. this.$message({
  243. type: "success",
  244. message: "操作成功!"
  245. });
  246. // 数据回调进行刷新
  247. done(row);
  248. }, error => {
  249. window.console.log(error);
  250. loading();
  251. });
  252. },
  253. //新增修改时保存触发
  254. rowSave(row, done, loading) {
  255. typeSave(row).then(res => {
  256. console.log(res)
  257. done()
  258. })
  259. },
  260. //查询全部
  261. initData() {
  262. customerList().then(res => {
  263. console.log(this.form);
  264. const column = this.findObject(this.option.column, "parentId");
  265. column.dicData = res.data.data.records;
  266. });
  267. },
  268. //新增子项触发
  269. handleAdd(row) {
  270. this.parentId = row.id;
  271. const column = this.findObject(this.option.column, "parentId");
  272. column.value = row.id;
  273. column.addDisabled = true;
  274. this.$refs.crud.rowAdd();
  275. },
  276. closeDetailPage() {
  277. this.isShow = true
  278. },
  279. //查看跳转页面
  280. beforeOpenPage(row, index) {
  281. this.detailData = {
  282. id: row.id,
  283. seeDisabled: true,
  284. };
  285. this.isShow = false;
  286. this.$store.commit("DOMXS_IN_DETAIL");
  287. },
  288. //新增跳转页面
  289. beforeOpen(row, index) {
  290. this.detailData = {
  291. id: row.id,
  292. };
  293. this.isShow = false;
  294. this.$store.commit("DOMXS_IN_DETAIL");
  295. },
  296. editOpen(row, index) {
  297. this.detailData = {
  298. id: row.id,
  299. };
  300. this.isShow = false;
  301. this.$store.commit("DOMXS_IN_DETAIL");
  302. },
  303. // 复制新单
  304. copyOrder() {
  305. const id = this.selection[0].id;
  306. this.detailData = {
  307. copyId: id,
  308. };
  309. this.isShow = false;
  310. this.$store.commit("DOMXS_IN_DETAIL");
  311. },
  312. //点击新增时触发
  313. beforeClose(done) {
  314. this.parentId = "";
  315. const column = this.findObject(this.option.column, "parentId");
  316. column.value = "";
  317. column.addDisabled = false;
  318. done();
  319. },
  320. //点击搜索按钮触发
  321. searchChange(params, done) {
  322. if (params.businesDate) {
  323. params.orderStartDate = params.businesDate[0]+ " " + "00:00:00"
  324. params.orderEndDate = params.businesDate[1]+ " " + "23:59:59"
  325. delete params.businesDate;
  326. }
  327. if (params.requiredDeliveryDate) {
  328. params.deliveryStartDate = params.requiredDeliveryDate[0]+ " " + "00:00:00"
  329. params.deliveryEndDate = params.requiredDeliveryDate[1]+ " " + "23:59:59"
  330. this.$delete(params,'requiredDeliveryDate')
  331. }
  332. if (params.requiredArrivalDate) {
  333. params.arrivalDateStart = params.requiredArrivalDate[0]+ " " + "00:00:00"
  334. params.arrivalDateEnd = params.requiredArrivalDate[1]+ " " + "23:59:59"
  335. this.$delete(params,'requiredArrivalDate')
  336. }
  337. if (params.actualDeliveryDate) {
  338. params.actualDeliveryDateStart = params.actualDeliveryDate[0]+ " " + "00:00:00"
  339. params.actualDeliveryDateEnd = params.actualDeliveryDate[1]+ " " + "23:59:59"
  340. this.$delete(params,'actualDeliveryDate')
  341. }
  342. if (params.createTime) {
  343. params.createTimeStart = params.createTime[0]+ " " + "00:00:00"
  344. params.createTimeEnd = params.createTime[1]+ " " + "23:59:59"
  345. this.$delete(params,'createTime')
  346. }
  347. this.page.currentPage = 1;
  348. this.onLoad(this.page, params);
  349. done()
  350. },
  351. searchReset() {
  352. this.configuration.dicData = []
  353. },
  354. // 选择框
  355. selectionChange(list) {
  356. this.selection = list;
  357. this.single = list.length !== 1;
  358. },
  359. currentChange(currentPage) {
  360. this.page.currentPage = currentPage;
  361. },
  362. sizeChange(pageSize) {
  363. this.page.pageSize = pageSize;
  364. },
  365. //列表刷新触发
  366. refreshChange() {
  367. this.dataList.forEach(item => {
  368. this.$refs.crud.toggleRowExpansion(item, false)
  369. })
  370. this.page.currentPage = 1;
  371. this.onLoad(this.page,this.search);
  372. },
  373. // 表格展开触发
  374. expandChange(row, index) {
  375. if (row.loading) {
  376. detail(row.id).then(res => {
  377. row.insideList = res.data.data.orderItemsList
  378. row.loading = false
  379. })
  380. }
  381. },
  382. onLoad(page, params) {
  383. // 重置掉展开
  384. this.dataList.forEach(item => {
  385. this.$refs.crud.toggleRowExpansion(item, false)
  386. })
  387. let data = this.gobackSearch(params)
  388. let queryParams = Object.assign({}, data, {
  389. size: page.pageSize,
  390. current: page.currentPage,
  391. billType:'XS',
  392. corpsTypeId: this.treeDeptId
  393. })
  394. this.loading = true;
  395. customerList(queryParams).then(res => {
  396. this.dataList = res.data.data.records
  397. this.dataList.forEach(item => {
  398. this.$set(item,'insideList',[])
  399. this.$set(item,'loading', true)
  400. })
  401. this.page.total = res.data.data.total
  402. }).finally(() => {
  403. this.loading = false;
  404. })
  405. },
  406. //树桩列点击展开触发
  407. treeLoad(tree, treeNode, resolve) {
  408. const parentId = tree.id;
  409. customerList({parentId: parentId}).then(res => {
  410. resolve(res.data.data.records);
  411. });
  412. },
  413. goBack() {
  414. this.detailData=this.$options.data().detailData
  415. if (this.$route.query) {
  416. this.$router.$avueRouter.closeTag();
  417. this.$router.push({
  418. path: "/businessManagement/salesOrder/index"
  419. });
  420. }
  421. this.dataList.forEach(item => {
  422. this.$refs.crud.toggleRowExpansion(item, false)
  423. })
  424. this.isShow = true;
  425. this.onLoad(this.page, this.search);
  426. },
  427. gobackSearch(params) {
  428. params = Object.assign({}, this.search)
  429. if (params.businesDate && params.businesDate != '') {
  430. params.orderStartDate = params.businesDate[0]+ " " + "00:00:00"
  431. params.orderEndDate = params.businesDate[1]+ " " + "23:59:59"
  432. this.$delete(params,'businesDate')
  433. }
  434. if (params.requiredDeliveryDate && params.requiredDeliveryDate != '') {
  435. params.deliveryStartDate = params.requiredDeliveryDate[0]+ " " + "00:00:00"
  436. params.deliveryEndDate = params.requiredDeliveryDate[1]+ " " + "23:59:59"
  437. this.$delete(params,'requiredDeliveryDate')
  438. }
  439. if (params.requiredArrivalDate && params.requiredArrivalDate != '') {
  440. params.arrivalDateStart = params.requiredArrivalDate[0]+ " " + "00:00:00"
  441. params.arrivalDateEnd = params.requiredArrivalDate[1]+ " " + "23:59:59"
  442. this.$delete(params,'requiredArrivalDate')
  443. }
  444. if (params.actualDeliveryDate && params.actualDeliveryDate != '') {
  445. params.actualDeliveryDateStart = params.actualDeliveryDate[0]+ " " + "00:00:00"
  446. params.actualDeliveryDateEnd = params.actualDeliveryDate[1]+ " " + "23:59:59"
  447. this.$delete(params,'actualDeliveryDate')
  448. }
  449. if (params.createTime && params.createTime != '') {
  450. params.createTimeStart = params.createTime[0]+ " " + "00:00:00"
  451. params.createTimeEnd = params.createTime[1]+ " " + "23:59:59"
  452. this.$delete(params,'createTime')
  453. }
  454. return params
  455. },
  456. //列保存触发
  457. async saveColumn() {
  458. /**
  459. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  460. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  461. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  462. */
  463. const inSave = await this.saveColumnData(
  464. this.getColumnName(14),
  465. this.option
  466. );
  467. if (inSave) {
  468. this.$message.success("保存成功");
  469. //关闭窗口
  470. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  471. }
  472. },
  473. async resetColumn() {
  474. this.option = option;
  475. const inSave = await this.delColumnData(
  476. this.getColumnName(14),
  477. option
  478. );
  479. if (inSave) {
  480. this.$message.success("重置成功");
  481. //关闭窗口
  482. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  483. }
  484. },
  485. }
  486. }
  487. </script>
  488. <style scoped>
  489. /deep/ .el-table__expanded-cell .el-table__header-wrapper .cell {
  490. font-size: 8px !important;
  491. }
  492. /deep/ .el-table__body-wrapper .cell {
  493. font-size: 8px;
  494. }
  495. </style>