index.vue 20 KB

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