index.vue 19 KB

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