index.vue 21 KB

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