index.vue 18 KB

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