index.vue 20 KB

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