index.vue 17 KB

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