index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <div>
  3. <basic-container v-show="isShow">
  4. <avue-crud :option="option" :data="dataList" ref="crud" v-model="form" :page.sync="page" :search.sync="search"
  5. :table-loading="loading" @row-del="rowDel" @row-update="rowUpdate" :before-open="beforeOpen"
  6. :before-close="beforeClose" @row-save="rowSave" @search-change="searchChange"
  7. @search-reset="searchReset"
  8. @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
  9. @refresh-change="refreshChange" @on-load="onLoad" @tree-load="treeLoad" @saveColumn="saveColumn"
  10. @resetColumn="resetColumn" @search-criteria-switch="searchCriteriaSwitch" :cell-style="cellStyle">
  11. <template slot="menuLeft" slot-scope="{size}">
  12. <el-button type="success" :size="size" @click="copyOrder" :disabled="single">复制单据</el-button>
  13. <el-button type="info" :size="size" icon="el-icon-printer">报表打印</el-button>
  14. <el-button type="warning" size="small" icon="el-icon-top" @click.stop="openExport()">导出</el-button>
  15. </template>
  16. <template slot-scope="scope" slot="orgOrderNo">
  17. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row, scope.index)">{{
  18. scope.row.orgOrderNo
  19. }}</span>
  20. </template>
  21. <template slot="corpIdSearch">
  22. <crop-select v-model="search.corpId" corpType="GYS"></crop-select>
  23. </template>
  24. <template slot-scope="scope" slot="corpId">
  25. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row, scope.index)">{{
  26. scope.row.corpsName
  27. }}</span>
  28. </template>
  29. <template slot="salesCompanySearch">
  30. <select-component v-model="search.salesCompany" :configuration="configuration"></select-component>
  31. </template>
  32. <template slot-scope="scope" slot="salesCompany">
  33. {{ scope.row.salesCompanyName }}
  34. </template>
  35. <template slot="storageIdSearch">
  36. <warehouseSelect v-model="search.storageId" :configuration="configurationWarehouse"></warehouseSelect>
  37. </template>
  38. <template slot-scope="scope" slot="storageId">
  39. {{ scope.row.storageName }}
  40. </template>
  41. <template slot-scope="scope" slot="createUser">
  42. {{ scope.row.createUserName }}
  43. </template>
  44. <template slot-scope="scope" slot="menu">
  45. <!-- <el-button-->
  46. <!-- type="text"-->
  47. <!-- icon="el-icon-edit"-->
  48. <!-- size="small"-->
  49. <!-- @click.stop="editOpen(scope.row,scope.index)"-->
  50. <!-- >编辑-->
  51. <!-- </el-button>-->
  52. <el-button
  53. type="text"
  54. icon="el-icon-delete"
  55. size="small"
  56. :disabled="scope.row.deliveryStatus !== '录入'"
  57. @click.stop="sendInGoods(scope.row, scope.index)">确认发货
  58. </el-button>
  59. <el-button
  60. type="text"
  61. icon="el-icon-delete"
  62. size="small"
  63. :disabled="scope.row.deliveryStatus === '已发货'"
  64. @click.stop="rowDel(scope.row, scope.index)">删除
  65. </el-button>
  66. </template>
  67. </avue-crud>
  68. </basic-container>
  69. <detail-page ref="detail" @goBack="goBack" :detailData="detailData" v-if="!isShow"></detail-page>
  70. </div>
  71. </template>
  72. <script>
  73. import option from "./configuration/mainList.json";
  74. import {customerList, typeSave, deleteDetails, sendInGoods} from "@/api/basicData/receipt"
  75. import detailPage from "./detailsPageEdit";
  76. import {defaultDate} from "@/util/date";
  77. import {gainUser} from "@/api/basicData/customerInquiry";
  78. import {getToken} from "@/util/auth";
  79. export default {
  80. name: "customerInformation",
  81. components: {
  82. detailPage
  83. },
  84. data() {
  85. return {
  86. configuration: {
  87. multipleChoices: false,
  88. multiple: false,
  89. collapseTags: false,
  90. placeholder: "请点击右边按钮选择",
  91. dicData: [],
  92. clearable: true,
  93. },
  94. configurationWarehouse: {
  95. multipleChoices: false,
  96. multiple: false,
  97. collapseTags: false,
  98. placeholder: "请点击右边按钮选择",
  99. dicData: [],
  100. clearable: true,
  101. },
  102. form: {},
  103. search: {},
  104. loading: false,
  105. option: {},
  106. parentId: 0,
  107. dataList: [],
  108. page: {
  109. pageSize: 10,
  110. currentPage: 1,
  111. total: 0,
  112. pageSizes: [10, 50, 100, 200, 300]
  113. },
  114. // 非单个禁用
  115. single: true,
  116. // 非多个禁用
  117. multiple: true,
  118. selection: [],
  119. isShow: true,
  120. detailData: {},
  121. }
  122. },
  123. async created() {
  124. // this.search.businessDate = defaultDate(1)
  125. this.search.createTime = defaultDate(3)
  126. // this.option = option
  127. this.option = await this.getColumnData(this.getColumnName(23), option);
  128. gainUser().then(res => {
  129. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  130. })
  131. this.getWorkDicts("procurement_method").then(res => {
  132. this.findObject(this.option.column, "purchaseMode").dicData =
  133. res.data.data;
  134. });
  135. let i = 0;
  136. this.option.column.forEach(item => {
  137. if (item.search) i++
  138. })
  139. if (i % 3 !== 0) {
  140. const num = 3 - Number(i % 3)
  141. this.option.searchMenuSpan = num * 8;
  142. this.option.searchMenuPosition = "right";
  143. }
  144. this.option.column.forEach(item => {
  145. if (item.pickerOptions) {
  146. item.pickerOptions = {
  147. shortcuts: [{
  148. text: '最近一周',
  149. onClick(picker) {
  150. const end = new Date();
  151. const start = new Date();
  152. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  153. picker.$emit('pick', [start, end]);
  154. }
  155. }, {
  156. text: '最近一个月',
  157. onClick(picker) {
  158. const end = new Date();
  159. const start = new Date();
  160. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  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 * 90);
  169. picker.$emit('pick', [start, end]);
  170. }
  171. }]
  172. }
  173. }
  174. })
  175. },
  176. activated() {
  177. // this.isShow = true;
  178. setTimeout(() => {
  179. if (this.$route.query.form) {
  180. this.detailData = {
  181. form: this.$route.query.form,
  182. };
  183. this.$store.commit("DOM_IN_DETAIL");
  184. this.isShow = false;
  185. }
  186. }, 100);
  187. },
  188. methods: {
  189. cellStyle() {
  190. return "padding:0;height:40px;";
  191. },
  192. searchCriteriaSwitch(type) {
  193. if (type) {
  194. this.option.height = this.option.height - 190
  195. } else {
  196. this.option.height = this.option.height + 190
  197. }
  198. this.$refs.crud.getTableHeight()
  199. },
  200. //确认发货
  201. sendInGoods(row) {
  202. this.$confirm("是否确认发货?", {
  203. confirmButtonText: "确定",
  204. cancelButtonText: "取消",
  205. type: "warning"
  206. }).then(() => {
  207. sendInGoods({id:row.id}).then(res => {
  208. this.$message.success('发货成功')
  209. this.onLoad(this.page, this.search)
  210. })
  211. });
  212. },
  213. //删除列表后面的删除按钮触发触发(row, index, done)
  214. rowDel(row, index, done) {
  215. this.$confirm("确定将选择数据删除?", {
  216. confirmButtonText: "确定",
  217. cancelButtonText: "取消",
  218. type: "warning"
  219. }).then(() => {
  220. return deleteDetails(row.id);
  221. }).then(() => {
  222. this.$message({
  223. type: "success",
  224. message: "操作成功!"
  225. });
  226. this.page.currentPage = 1;
  227. this.onLoad(this.page, {parentId: 0});
  228. });
  229. },
  230. //修改时的修改按钮点击触发
  231. rowUpdate(row, index, done, loading) {
  232. typeSave(row).then(() => {
  233. this.$message({
  234. type: "success",
  235. message: "操作成功!"
  236. });
  237. // 数据回调进行刷新
  238. done(row);
  239. }, error => {
  240. window.console.log(error);
  241. loading();
  242. });
  243. },
  244. //新增修改时保存触发
  245. rowSave(row, done, loading) {
  246. typeSave(row).then(res => {
  247. console.log(res)
  248. done()
  249. })
  250. },
  251. //查询全部
  252. initData() {
  253. customerList().then(res => {
  254. console.log(this.form);
  255. const column = this.findObject(this.option.column, "parentId");
  256. column.dicData = res.data.data.records;
  257. });
  258. },
  259. //新增子项触发
  260. handleAdd(row) {
  261. this.parentId = row.id;
  262. const column = this.findObject(this.option.column, "parentId");
  263. column.value = row.id;
  264. column.addDisabled = true;
  265. this.$refs.crud.rowAdd();
  266. },
  267. //查看跳转页面
  268. beforeOpenPage(row, index) {
  269. const data = {
  270. moduleName: 'sh',
  271. tableName: 'business_delivery',
  272. billId: row.id,
  273. no: localStorage.getItem('browserID')
  274. }
  275. this.checkLock(data).then(res => {
  276. if (res.data.code == 200) {
  277. this.detailData = {
  278. seeDisabled: true,
  279. id: row.id,
  280. };
  281. this.isShow = false;
  282. this.$store.commit("DOM_IN_DETAIL");
  283. }
  284. }).catch(err => {
  285. this.detailData = {
  286. id: row.id,
  287. seeDisabled: true,
  288. opDisabled: true
  289. };
  290. this.isShow = false;
  291. this.$store.commit("DOM_IN_DETAIL");
  292. })
  293. },
  294. //新增跳转页面
  295. beforeOpen(row, index) {
  296. this.detailData = {
  297. id: row.id,
  298. };
  299. this.isShow = false;
  300. this.$store.commit("DOM_IN_DETAIL");
  301. },
  302. editOpen(row, index) {
  303. this.detailData = {
  304. id: row.id,
  305. };
  306. this.isShow = false;
  307. this.$store.commit("DOM_IN_DETAIL");
  308. },
  309. // 复制新单
  310. copyOrder() {
  311. const id = this.selection[0].id;
  312. this.detailData = {
  313. copyId: id,
  314. };
  315. this.isShow = false;
  316. this.$store.commit("DOM_IN_DETAIL");
  317. },
  318. //点击新增时触发
  319. beforeClose(done) {
  320. this.parentId = "";
  321. const column = this.findObject(this.option.column, "parentId");
  322. column.value = "";
  323. column.addDisabled = false;
  324. done();
  325. },
  326. //点击搜索按钮触发
  327. searchChange(params, done) {
  328. // if (params.businessDate) {
  329. // this.$set(params, 'businessStartDate', params.businessDate[0] + " " + "00:00:00")
  330. // this.$set(params, 'businessEndDate', params.businessDate[1] + " " + "23:59:59")
  331. // this.$delete(params, 'businessDate')
  332. // }
  333. if (params.createTime) {
  334. this.$set(params, 'createStartTime', params.createTime[0] + " " + "00:00:00")
  335. this.$set(params, 'createEndTime', params.createTime[1] + " " + "23:59:59")
  336. this.$delete(params, 'createTime')
  337. }
  338. this.page.currentPage = 1;
  339. this.onLoad(this.page, params);
  340. done()
  341. },
  342. searchReset() {
  343. console.log('1')
  344. },
  345. selectionChange(list) {
  346. this.selection = list;
  347. this.single = list.length !== 1;
  348. },
  349. currentChange(currentPage) {
  350. this.page.currentPage = currentPage;
  351. },
  352. sizeChange(pageSize) {
  353. this.page.pageSize = pageSize;
  354. },
  355. refreshChange() {
  356. this.page.currentPage = 1;
  357. this.onLoad(this.page, this.search);
  358. },
  359. openExport() {
  360. let queryParams = this.search
  361. if (queryParams.createTime) {
  362. queryParams.createStartTime = queryParams.createTime[0]
  363. queryParams.createEndTime = queryParams.createTime[1]
  364. delete queryParams.createTime
  365. }
  366. if (queryParams.businessDate) {
  367. this.$set(queryParams, 'businessStartDate', queryParams.businessDate[0] + " " + "00:00:00")
  368. this.$set(queryParams, 'businessEndDate', queryParams.businessDate[1] + " " + "23:59:59")
  369. this.$delete(queryParams, 'businessDate')
  370. }
  371. const routeData = this.$router.resolve({
  372. path: '/api/blade-deliver-goods/reCeVing/exportOutFactoryDelivery', //跳转目标窗口的地址
  373. query: {
  374. ...queryParams //括号内是要传递给新窗口的参数
  375. }
  376. })
  377. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  378. },
  379. onLoad(page, params) {
  380. let data = this.gobackSearch(params)
  381. let queryParams = Object.assign({}, data, {
  382. size: page.pageSize,
  383. current: page.currentPage,
  384. billType: 'SH',
  385. corpsTypeId: this.treeDeptId
  386. })
  387. this.loading = true;
  388. customerList(queryParams).then(res => {
  389. this.dataList = res.data.data.records
  390. this.page.total = res.data.data.total
  391. this.option.height = window.innerHeight - 240;
  392. }).finally(() => {
  393. this.loading = false;
  394. })
  395. },
  396. //树桩列点击展开触发
  397. treeLoad(tree, treeNode, resolve) {
  398. const parentId = tree.id;
  399. customerList({parentId: parentId}).then(res => {
  400. resolve(res.data.data.records);
  401. });
  402. },
  403. goBack() {
  404. this.detailData = this.$options.data().detailData
  405. if (this.$route.query.form) {
  406. this.$router.$avueRouter.closeTag();
  407. this.$router.push({
  408. path: "/businessManagement/receipt/index"
  409. });
  410. }
  411. this.isShow = true;
  412. this.$store.commit("DOM_OUT_DETAIL");
  413. this.onLoad(this.page, this.search)
  414. },
  415. gobackSearch(params) {
  416. params = Object.assign({}, this.search)
  417. if (params.businessDate && params.businessDate != '') {
  418. this.$set(params, 'businessStartDate', params.businessDate[0] + " " + "00:00:00")
  419. this.$set(params, 'businessEndDate', params.businessDate[1] + " " + "23:59:59")
  420. this.$delete(params, 'businessDate')
  421. }
  422. if (params.createTime && params.createTime != '') {
  423. this.$set(params, 'createStartTime', params.createTime[0] + " " + "00:00:00")
  424. this.$set(params, 'createEndTime', params.createTime[1] + " " + "23:59:59")
  425. this.$delete(params, 'createTime')
  426. }
  427. return params
  428. },
  429. //列保存触发
  430. async saveColumn() {
  431. /**
  432. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  433. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  434. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  435. */
  436. const inSave = await this.saveColumnData(
  437. this.getColumnName(23),
  438. this.option
  439. );
  440. if (inSave) {
  441. this.$message.success("保存成功");
  442. //关闭窗口
  443. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  444. this.$nextTick(() => {
  445. this.$refs.crud.doLayout()
  446. })
  447. }
  448. },
  449. async resetColumn() {
  450. this.option = option;
  451. const inSave = await this.delColumnData(
  452. this.getColumnName(23),
  453. option
  454. );
  455. if (inSave) {
  456. this.$nextTick(() => {
  457. this.$refs.crud.doLayout()
  458. })
  459. this.$message.success("重置成功");
  460. //关闭窗口
  461. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  462. }
  463. },
  464. }
  465. }
  466. </script>
  467. <style scoped>
  468. </style>