index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <div>
  3. <basic-container v-if="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. :cell-style="cellStyle"
  19. >
  20. <template slot="createTimeSearch">
  21. <el-date-picker
  22. v-model="search.createTime"
  23. type="daterange"
  24. start-placeholder="开始日期"
  25. end-placeholder="结束日期"
  26. format="yyyy-MM-dd"
  27. value-format="yyyy-MM-dd HH:mm:ss"
  28. :default-time="['00:00:00', '23:59:59']"
  29. >
  30. </el-date-picker>
  31. </template>
  32. <template slot="menuLeft">
  33. <el-button
  34. type="primary"
  35. icon="el-icon-plus"
  36. size="small"
  37. @click.stop="newAdd('new')"
  38. >新单</el-button
  39. >
  40. <el-button type="success" size="small" disabled>复制新单</el-button>
  41. <el-button type="info" size="small">报表</el-button>
  42. </template>
  43. <template slot="corpIdSearch">
  44. <select-component
  45. v-model="search.corpId"
  46. :configuration="configuration"
  47. ></select-component>
  48. </template>
  49. <template slot="businesDateSearch">
  50. <el-date-picker
  51. v-model="search.businesDate"
  52. type="daterange"
  53. start-placeholder="开始日期"
  54. end-placeholder="结束日期"
  55. format="yyyy-MM-dd"
  56. value-format="yyyy-MM-dd HH:mm:ss"
  57. :default-time="['00:00:00', '23:59:59']"
  58. >
  59. </el-date-picker>
  60. </template>
  61. <template slot="plannedDeliveryDateSearch">
  62. <el-date-picker
  63. v-model="search.plannedDeliveryDate"
  64. type="daterange"
  65. start-placeholder="开始日期"
  66. end-placeholder="结束日期"
  67. format="yyyy-MM-dd"
  68. value-format="yyyy-MM-dd HH:mm:ss"
  69. :default-time="['00:00:00', '23:59:59']"
  70. >
  71. </el-date-picker>
  72. </template>
  73. <template slot="requiredDeliveryDateSearch">
  74. <el-date-picker
  75. v-model="search.requiredDeliveryDate"
  76. type="daterange"
  77. start-placeholder="开始日期"
  78. end-placeholder="结束日期"
  79. format="yyyy-MM-dd"
  80. value-format="yyyy-MM-dd HH:mm:ss"
  81. :default-time="['00:00:00', '23:59:59']"
  82. >
  83. </el-date-picker>
  84. </template>
  85. <template slot-scope="scope" slot="corpId">
  86. {{ scope.row.strCorpName }}
  87. </template>
  88. <template slot-scope="scope" slot="createUser">
  89. {{ scope.row.createUserName }}
  90. </template>
  91. <template slot-scope="scope" slot="menu">
  92. <el-button
  93. type="text"
  94. icon="el-icon-edit"
  95. size="small"
  96. @click.stop="editOpen(scope.row, 2)"
  97. >编辑
  98. </el-button>
  99. <el-button
  100. type="text"
  101. icon="el-icon-delete"
  102. size="small"
  103. @click.stop="rowDel(scope.row, scope.index)"
  104. >删除
  105. </el-button>
  106. </template>
  107. </avue-crud>
  108. </basic-container>
  109. <detail-page @goBack="goBack" :detailData="detailData" v-else></detail-page>
  110. </div>
  111. </template>
  112. <script>
  113. import option from "./config/mainList.json";
  114. import { getList, remove, gainUser } from "@/api/exportTrade/purchaseContract";
  115. import detailPage from "./detailsPage.vue";
  116. import { defaultDate } from "@/util/date";
  117. export default {
  118. name: "customerInformation",
  119. data() {
  120. return {
  121. configuration: {
  122. multipleChoices: false,
  123. multiple: false,
  124. collapseTags: false,
  125. placeholder: "请点击右边按钮选择",
  126. dicData: []
  127. },
  128. search: {
  129. businesDate: defaultDate()
  130. },
  131. form: {},
  132. option: {},
  133. parentId: 0,
  134. dataList: [],
  135. page: {
  136. pageSize: 10,
  137. currentPage: 1,
  138. total: 0
  139. },
  140. show: true,
  141. detailData: {},
  142. loading: false
  143. };
  144. },
  145. components: { detailPage },
  146. async created() {
  147. this.option = await this.getColumnData(this.getColumnName(2), option);
  148. let _this = this;
  149. this.option.column.forEach(e => {
  150. if (e.prop == "exchangeRate") {
  151. e.formatter = function(row) {
  152. return _this.textFormat(
  153. Number(row.exchangeRate ? row.exchangeRate : 0) / 100,
  154. "0.00%"
  155. );
  156. };
  157. }
  158. if (e.prop == "creditAmount") {
  159. e.formatter = function(row) {
  160. return _this.textFormat(
  161. Number(row.creditAmount ? row.creditAmount : 0),
  162. "#,##0.00"
  163. );
  164. };
  165. }
  166. });
  167. this.getWorkDicts("payment_term").then(res => {
  168. this.findObject(this.option.column, "paymentType").dicData =
  169. res.data.data;
  170. });
  171. gainUser().then(res => {
  172. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  173. });
  174. },
  175. methods: {
  176. cellStyle() {
  177. return "padding:0;height:40px;";
  178. },
  179. //删除列表后面的删除按钮触发触发(row, index, done)
  180. rowDel(row, index, done) {
  181. this.$confirm("确定删除数据?", {
  182. confirmButtonText: "确定",
  183. cancelButtonText: "取消",
  184. type: "warning"
  185. }).then(() => {
  186. remove(row.id).then(res => {
  187. if (res.data.code == 200) {
  188. this.$message({
  189. type: "success",
  190. message: "删除成功!"
  191. });
  192. this.onLoad(this.page, this.search);
  193. }
  194. });
  195. });
  196. },
  197. //查看跳转页面
  198. beforeOpenPage(row, status) {
  199. this.detailData = {
  200. id: row.id,
  201. status: status
  202. };
  203. this.show = false;
  204. },
  205. editOpen(row, status) {
  206. this.detailData = {
  207. id: row.id,
  208. status: status
  209. };
  210. this.show = false;
  211. },
  212. //点击搜索按钮触发
  213. searchChange(params, done) {
  214. if (params.businesDate) {
  215. params.businesStartDate = params.businesDate[0];
  216. params.businesEndDate = params.businesDate[1];
  217. }
  218. if (params.requiredDeliveryDate) {
  219. params.requiredDeliveryStartDate = params.requiredDeliveryDate[0];
  220. params.requiredDeliveryEndDate = params.requiredDeliveryDate[1];
  221. }
  222. delete params.businesDate;
  223. delete params.requiredDeliveryDate;
  224. this.page.currentPage = 1;
  225. this.onLoad(this.page, params);
  226. done();
  227. },
  228. currentChange(val) {
  229. this.page.currentPage = val;
  230. },
  231. sizeChange(val) {
  232. this.page.currentPage = 1;
  233. this.page.pageSize = val;
  234. },
  235. onLoad(page, params) {
  236. if (this.search.businesDate && this.search.businesDate.length > 0) {
  237. params = {
  238. ...params,
  239. orderStartDate: this.search.businesDate[0],
  240. orderEndDate: this.search.businesDate[1]
  241. };
  242. delete params.businesDate;
  243. }
  244. this.loading = true;
  245. getList(page.currentPage, page.pageSize, params)
  246. .then(res => {
  247. this.dataList = res.data.data.records ? res.data.data.records : [];
  248. this.page.total = res.data.data.total;
  249. if (this.page.total) {
  250. this.option.height = window.innerHeight - 350;
  251. }
  252. })
  253. .finally(() => {
  254. this.loading = false;
  255. });
  256. },
  257. refreshChange() {
  258. this.onLoad(this.page, this.search);
  259. },
  260. newAdd(type) {
  261. this.detailData = {
  262. pageType: type
  263. };
  264. this.show = false;
  265. },
  266. goBack() {
  267. this.detailData = this.$options.data().detailData;
  268. this.show = true;
  269. },
  270. async saveColumn() {
  271. const inSave = await this.saveColumnData(
  272. this.getColumnName(2),
  273. this.option
  274. );
  275. if (inSave) {
  276. this.$message.success("保存成功");
  277. //关闭窗口
  278. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  279. }
  280. }
  281. },
  282. watch: {
  283. option: function() {
  284. this.search.businesDate = defaultDate();
  285. }
  286. }
  287. };
  288. </script>
  289. <style scoped>
  290. ::v-deep .select-component {
  291. display: flex;
  292. }
  293. .page-crad ::v-deep .basic-container__card {
  294. height: 94.2vh;
  295. }
  296. </style>