index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. v-model="form"
  9. :page.sync="page"
  10. :search.sync="search"
  11. @search-change="searchChange"
  12. @current-change="currentChange"
  13. @size-change="sizeChange"
  14. @refresh-change="refreshChange"
  15. @on-load="onLoad"
  16. :table-loading="loading"
  17. @saveColumn="saveColumn"
  18. @resetColumn="resetColumn"
  19. :cell-style="cellStyle"
  20. @selection-change="selectionChange"
  21. @search-criteria-switch="searchCriteriaSwitch"
  22. >
  23. <template slot="createTimeSearch">
  24. <el-date-picker
  25. v-model="search.createTime"
  26. type="daterange"
  27. start-placeholder="开始日期"
  28. end-placeholder="结束日期"
  29. format="yyyy-MM-dd"
  30. value-format="yyyy-MM-dd HH:mm:ss"
  31. :default-time="['00:00:00', '23:59:59']"
  32. >
  33. </el-date-picker>
  34. </template>
  35. <template slot="menuLeft">
  36. <el-button
  37. type="primary"
  38. icon="el-icon-plus"
  39. size="small"
  40. @click.stop="newAdd('new')"
  41. >创建单据
  42. </el-button>
  43. <el-button
  44. type="success"
  45. size="small"
  46. @click.stop="copyDoc()"
  47. :disabled="selectionList.length != 1"
  48. >复制单据</el-button
  49. >
  50. <el-button type="info" size="small">报表打印</el-button>
  51. </template>
  52. <template slot="corpIdSearch">
  53. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  54. </template>
  55. <template slot="businesDateSearch">
  56. <el-date-picker
  57. v-model="search.businesDate"
  58. type="daterange"
  59. start-placeholder="开始日期"
  60. end-placeholder="结束日期"
  61. format="yyyy-MM-dd"
  62. value-format="yyyy-MM-dd HH:mm:ss"
  63. :default-time="['00:00:00', '23:59:59']"
  64. >
  65. </el-date-picker>
  66. </template>
  67. <template slot="plannedDeliveryDateSearch">
  68. <el-date-picker
  69. v-model="search.plannedDeliveryDate"
  70. type="daterange"
  71. start-placeholder="开始日期"
  72. end-placeholder="结束日期"
  73. format="yyyy-MM-dd"
  74. value-format="yyyy-MM-dd HH:mm:ss"
  75. :default-time="['00:00:00', '23:59:59']"
  76. >
  77. </el-date-picker>
  78. </template>
  79. <template slot="requiredDeliveryDateSearch">
  80. <el-date-picker
  81. v-model="search.requiredDeliveryDate"
  82. type="daterange"
  83. start-placeholder="开始日期"
  84. end-placeholder="结束日期"
  85. format="yyyy-MM-dd"
  86. value-format="yyyy-MM-dd HH:mm:ss"
  87. :default-time="['00:00:00', '23:59:59']"
  88. >
  89. </el-date-picker>
  90. </template>
  91. <template slot-scope="scope" slot="corpId">
  92. <span
  93. style="color: #409EFF;cursor: pointer"
  94. @click.stop="editOpen(scope.row, 1)"
  95. >{{ scope.row.strCorpName }}
  96. </span>
  97. </template>
  98. <template slot-scope="scope" slot="orderNo">
  99. <span
  100. style="color: #409EFF;cursor: pointer"
  101. @click.stop="editOpen(scope.row, 1)"
  102. >{{ scope.row.orderNo }}
  103. </span>
  104. </template>
  105. <template slot-scope="scope" slot="createUser">
  106. {{ scope.row.createUserName }}
  107. </template>
  108. <template slot-scope="{ row }" slot="orderQuantity">
  109. <span>{{ row.orderQuantity | IntegerFormat }}</span>
  110. </template>
  111. <template slot-scope="scope" slot="menu">
  112. <el-button
  113. type="text"
  114. icon="el-icon-delete"
  115. size="small"
  116. @click.stop="rowDel(scope.row, scope.index)"
  117. >删除
  118. </el-button>
  119. </template>
  120. </avue-crud>
  121. </basic-container>
  122. <detail-page
  123. @goBack="goBack"
  124. @copyOrder="copyOrder"
  125. :detailData="detailData"
  126. v-if="!show"
  127. ></detail-page>
  128. </div>
  129. </template>
  130. <script>
  131. import option from "./config/mainList.json";
  132. import { getList, remove, gainUser } from "@/api/exportTrade/purchaseContract";
  133. import detailPage from "./detailsPage.vue";
  134. import { defaultDate } from "@/util/date";
  135. import { IntegerFormat } from "@/util/validate";
  136. export default {
  137. name: "customerInformation",
  138. data() {
  139. return {
  140. search: {
  141. businesDate: defaultDate()
  142. },
  143. form: {},
  144. option: {},
  145. parentId: 0,
  146. dataList: [],
  147. page: {
  148. pageSize: 20,
  149. currentPage: 1,
  150. total: 0,
  151. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  152. },
  153. show: true,
  154. detailData: {},
  155. loading: false,
  156. selectionList: []
  157. };
  158. },
  159. components: { detailPage },
  160. async created() {
  161. this.option = await this.getColumnData(this.getColumnName(2), option);
  162. this.getWorkDicts("payment_term").then(res => {
  163. this.findObject(this.option.column, "paymentType").dicData =
  164. res.data.data;
  165. });
  166. gainUser().then(res => {
  167. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  168. });
  169. this.option.height = window.innerHeight - 210;
  170. },
  171. filters: {
  172. IntegerFormat(num) {
  173. return IntegerFormat(num);
  174. }
  175. },
  176. methods: {
  177. searchCriteriaSwitch(type) {
  178. if (type) {
  179. this.option.height = this.option.height - 139;
  180. } else {
  181. this.option.height = this.option.height + 139;
  182. }
  183. this.$refs.crud.getTableHeight();
  184. },
  185. cellStyle() {
  186. return "padding:0;height:40px;";
  187. },
  188. //删除列表后面的删除按钮触发触发(row, index, done)
  189. rowDel(row, index, done) {
  190. this.$confirm("确定删除数据?", {
  191. confirmButtonText: "确定",
  192. cancelButtonText: "取消",
  193. type: "warning"
  194. }).then(() => {
  195. remove(row.id).then(res => {
  196. if (res.data.code == 200) {
  197. this.$message({
  198. type: "success",
  199. message: "删除成功!"
  200. });
  201. this.onLoad(this.page, this.search);
  202. }
  203. });
  204. });
  205. },
  206. selectionChange(list) {
  207. this.selectionList = list;
  208. },
  209. copyDoc() {
  210. this.selectionList.forEach(e => {
  211. this.detailData = {
  212. id: e.id,
  213. status: "copy"
  214. };
  215. this.show = false;
  216. });
  217. },
  218. copyOrder(id) {
  219. this.show = true;
  220. this.detailData = {
  221. id: id,
  222. status: "copy"
  223. };
  224. this.$nextTick(() => {
  225. this.show = false;
  226. });
  227. },
  228. editOpen(row, status) {
  229. this.detailData = {
  230. id: row.id,
  231. status: status
  232. };
  233. this.show = false;
  234. },
  235. //点击搜索按钮触发
  236. searchChange(params, done) {
  237. if (params.businesDate) {
  238. params.businesStartDate = params.businesDate[0];
  239. params.businesEndDate = params.businesDate[1];
  240. }
  241. if (params.requiredDeliveryDate) {
  242. params.requiredDeliveryStartDate = params.requiredDeliveryDate[0];
  243. params.requiredDeliveryEndDate = params.requiredDeliveryDate[1];
  244. }
  245. delete params.businesDate;
  246. delete params.requiredDeliveryDate;
  247. this.page.currentPage = 1;
  248. this.onLoad(this.page, params);
  249. done();
  250. },
  251. currentChange(val) {
  252. this.page.currentPage = val;
  253. },
  254. sizeChange(val) {
  255. this.page.currentPage = 1;
  256. this.page.pageSize = val;
  257. },
  258. onLoad(page, params) {
  259. if (this.search.businesDate && this.search.businesDate.length > 0) {
  260. params = {
  261. ...params,
  262. orderStartDate: this.search.businesDate[0],
  263. orderEndDate: this.search.businesDate[1]
  264. };
  265. delete params.businesDate;
  266. }
  267. this.loading = true;
  268. getList(page.currentPage, page.pageSize, params)
  269. .then(res => {
  270. this.dataList = res.data.data.records ? res.data.data.records : [];
  271. this.page.total = res.data.data.total;
  272. })
  273. .finally(() => {
  274. this.loading = false;
  275. });
  276. },
  277. refreshChange() {
  278. this.onLoad(this.page, this.search);
  279. },
  280. newAdd(type) {
  281. this.detailData = {
  282. pageType: type
  283. };
  284. this.show = false;
  285. },
  286. goBack() {
  287. this.detailData = this.$options.data().detailData;
  288. this.show = true;
  289. this.onLoad(this.page, this.search);
  290. },
  291. async saveColumn() {
  292. const inSave = await this.saveColumnData(
  293. this.getColumnName(2),
  294. this.option
  295. );
  296. if (inSave) {
  297. this.$nextTick(() => {
  298. this.$refs.crud.doLayout();
  299. });
  300. this.$message.success("保存成功");
  301. //关闭窗口
  302. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  303. }
  304. },
  305. async resetColumn() {
  306. this.option = option;
  307. const inSave = await this.delColumnData(this.getColumnName(2), option);
  308. if (inSave) {
  309. this.$nextTick(() => {
  310. this.$refs.crud.doLayout();
  311. });
  312. this.$message.success("重置成功");
  313. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  314. }
  315. }
  316. },
  317. watch: {
  318. option: function() {
  319. this.search.businesDate = defaultDate();
  320. }
  321. }
  322. };
  323. </script>
  324. <style scoped>
  325. ::v-deep .select-component {
  326. display: flex;
  327. }
  328. .page-crad ::v-deep .basic-container__card {
  329. height: 94.2vh;
  330. }
  331. </style>