index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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.corpsName }}
  87. </template>
  88. <template slot-scope="scope" slot="menu">
  89. <el-button
  90. type="text"
  91. icon="el-icon-view"
  92. size="small"
  93. @click.stop="beforeOpenPage(scope.row, 1)"
  94. >查看
  95. </el-button>
  96. <el-button
  97. type="text"
  98. icon="el-icon-edit"
  99. size="small"
  100. @click.stop="editOpen(scope.row, 2)"
  101. >编辑
  102. </el-button>
  103. <el-button
  104. type="text"
  105. icon="el-icon-delete"
  106. size="small"
  107. @click.stop="rowDel(scope.row, scope.index)"
  108. >删除
  109. </el-button>
  110. </template>
  111. </avue-crud>
  112. </basic-container>
  113. <detail-page @goBack="goBack" :detailData="detailData" v-else></detail-page>
  114. </div>
  115. </template>
  116. <script>
  117. import option from "./config/mainList.json";
  118. import { getList, remove } from "@/api/exportTrade/purchaseContract";
  119. import detailPage from "./detailsPage.vue";
  120. import { defaultDate } from "@/util/date";
  121. export default {
  122. name: "customerInformation",
  123. data() {
  124. return {
  125. configuration: {
  126. multipleChoices: false,
  127. multiple: false,
  128. collapseTags: false,
  129. placeholder: "请点击右边按钮选择",
  130. dicData: []
  131. },
  132. search: {},
  133. form: {},
  134. option: {},
  135. parentId: 0,
  136. dataList: [],
  137. page: {
  138. pageSize: 10,
  139. currentPage: 1,
  140. total: 0
  141. },
  142. show: true,
  143. detailData: {},
  144. loading: false
  145. };
  146. },
  147. components: { detailPage },
  148. async created() {
  149. this.search.businesDate = defaultDate();
  150. this.option = await this.getColumnData(this.getColumnName(2), option);
  151. let _this = this;
  152. this.option.column.forEach(e => {
  153. if (e.prop == "exchangeRate") {
  154. e.formatter = function(row) {
  155. return _this.textFormat(
  156. Number(row.exchangeRate ? row.exchangeRate : 0) / 100,
  157. "0.00%"
  158. );
  159. };
  160. }
  161. if (e.prop == "creditAmount") {
  162. e.formatter = function(row) {
  163. return _this.textFormat(
  164. Number(row.creditAmount ? row.creditAmount : 0),
  165. "#,##0.00"
  166. );
  167. };
  168. }
  169. });
  170. this.getWorkDicts("payment_term").then(res => {
  171. this.findObject(this.option.column, "paymentType").dicData =
  172. 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);
  187. this.$message({
  188. type: "success",
  189. message: "删除成功!"
  190. });
  191. this.page.currentPage = 1;
  192. this.onLoad(this.page);
  193. });
  194. },
  195. //查看跳转页面
  196. beforeOpenPage(row, status) {
  197. this.detailData = {
  198. id: row.id,
  199. status: status
  200. };
  201. this.show = false;
  202. },
  203. editOpen(row, status) {
  204. this.detailData = {
  205. id: row.id,
  206. status: status
  207. };
  208. this.show = false;
  209. },
  210. //点击搜索按钮触发
  211. searchChange(params, done) {
  212. if (params.businesDate) {
  213. params.businesStartDate = params.businesDate[0];
  214. params.businesEndDate = params.businesDate[1];
  215. }
  216. if (params.requiredDeliveryDate) {
  217. params.requiredDeliveryStartDate = params.requiredDeliveryDate[0];
  218. params.requiredDeliveryEndDate = params.requiredDeliveryDate[1];
  219. }
  220. delete params.businesDate;
  221. delete params.requiredDeliveryDate;
  222. this.page.currentPage = 1;
  223. this.onLoad(this.page, params);
  224. done();
  225. },
  226. currentChange(val) {
  227. this.page.currentPage = val;
  228. },
  229. sizeChange(val) {
  230. this.page.currentPage = 1;
  231. this.page.pageSize = val;
  232. },
  233. onLoad(page, params) {
  234. if (this.search.businesDate && this.search.businesDate.length > 0) {
  235. params = {
  236. ...params,
  237. orderStartDate: this.search.businesDate[0],
  238. orderEndDate: this.search.businesDate[1]
  239. };
  240. delete params.businesDate;
  241. }
  242. this.loading = true;
  243. getList(page.currentPage, page.pageSize, params)
  244. .then(res => {
  245. this.dataList = res.data.data.records ? res.data.data.records : [];
  246. this.page.total = res.data.data.total;
  247. if (this.page.total) {
  248. this.option.height = window.innerHeight - 380;
  249. } else {
  250. this.option.height = window.innerHeight - 305;
  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. };
  283. </script>
  284. <style scoped>
  285. ::v-deep .select-component {
  286. display: flex;
  287. }
  288. .page-crad ::v-deep .basic-container__card {
  289. height: 86.5vh;
  290. }
  291. </style>