index.vue 14 KB

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