index.vue 16 KB

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