index.vue 16 KB

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