allOrders.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <span>
  5. <span>
  6. {{ $t("btOrder.orderMemberName") }}:
  7. </span>
  8. <span>
  9. <el-input
  10. class="filter-item search-item"
  11. v-model="queryParams.model.orderMemberName"
  12. />
  13. </span>
  14. <span>
  15. {{ $t("btOrder.id") }}:
  16. <el-input
  17. class="filter-item search-item"
  18. v-model="queryParams.model.id"
  19. />
  20. </span>
  21. <span>
  22. <el-date-picker
  23. v-model="queryParams.timeRange"
  24. type="datetimerange"
  25. range-separator="至"
  26. start-placeholder="开始日期"
  27. end-placeholder="结束日期">
  28. </el-date-picker>
  29. </span>
  30. <span>
  31. {{ $t("btOrder.orderStatus") }}:
  32. <el-select v-model="queryParams.model.orderStatus">
  33. <el-option
  34. v-for="item in statusOptions"
  35. :key="item.value"
  36. :label="item.label"
  37. :value="item.value">
  38. </el-option>
  39. </el-select>
  40. </span>
  41. </span>
  42. <!--操作按钮-->
  43. <span>
  44. <el-button @click="search" class="filter-item" plain type="primary">
  45. {{ $t("table.search") }}
  46. </el-button>
  47. <el-button @click="reset" class="filter-item" plain type="warning">
  48. {{ $t("table.reset") }}
  49. </el-button>
  50. </span>
  51. </div>
  52. <!-- 表格-->
  53. <el-table :data="tableData.records" :key="tableKey" @cell-click="cellClick"
  54. @filter-change="filterChange" @selection-change="onSelectChange" @sort-change="sortChange"
  55. border fit row-key="id" ref="table" style="width: 100%;" v-loading="loading" height="400">
  56. <el-table-column align="center" type="selection" width="40px" :reserve-selection="true"/>
  57. <el-table-column :label="$t('btOrder.id')" :show-overflow-tooltip="true" align="center"
  58. prop="id"
  59. width="">
  60. <template slot-scope="scope">
  61. <span>{{ scope.row.id }}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column :label="$t('btOrder.orderGoodsName')" :show-overflow-tooltip="true" align="center"
  65. prop="orderGoodsName"
  66. width="">
  67. <template slot-scope="scope">
  68. <span>{{ scope.row.orderGoodsName }}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column :label="$t('btOrder.orderGoodsPic')" :show-overflow-tooltip="true" align="center"
  72. prop="orderGoodsPic"
  73. width="">
  74. <template slot-scope="scope">
  75. <img :src="scope.row.orderGoodsPic" min-width="70" height="70"/>
  76. </template>
  77. </el-table-column>
  78. <el-table-column :label="$t('btOrder.equ')" :show-overflow-tooltip="true" align="center"
  79. prop="orderGoodsId"
  80. width="">
  81. <template slot-scope="scope">
  82. <span>{{ scope.row.deviceName }}</span>
  83. </template>
  84. </el-table-column>
  85. <el-table-column :label="$t('btOrder.orderMemberName')" :show-overflow-tooltip="true" align="center"
  86. prop="orderMemberName"
  87. width="">
  88. <template slot-scope="scope">
  89. <span>{{ scope.row.orderMemberName }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column :label="$t('btOrder.orderUnitPrice')" :show-overflow-tooltip="true" align="center"
  93. prop="orderCompanyId"
  94. width="">
  95. <template slot-scope="scope">
  96. <span>{{ scope.row.orderUnitPrice }}</span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column :label="$t('btOrder.orderGoodsAmount')" :show-overflow-tooltip="true" align="center"
  100. prop="orderSpecs"
  101. width="">
  102. <template slot-scope="scope">
  103. <span>{{ scope.row.orderGoodsAmount }}</span>
  104. </template>
  105. </el-table-column>
  106. <el-table-column :label="$t('btOrder.orderAmount')" :show-overflow-tooltip="true" align="center"
  107. prop="orderUnitPrice"
  108. width="">
  109. <template slot-scope="scope">
  110. <span>{{ scope.row.orderUnitPrice }}</span>
  111. </template>
  112. </el-table-column>
  113. <el-table-column :label="$t('btOrder.orderCreateTime')" :show-overflow-tooltip="true" align="center"
  114. prop="orderCreateTime"
  115. width="">
  116. <template slot-scope="scope">
  117. <span>{{ scope.row.createTime }}</span>
  118. </template>
  119. </el-table-column>
  120. <el-table-column :label="$t('btOrder.orderStatus')" :show-overflow-tooltip="true" align="center"
  121. prop="goodsCateStatus" width="80px">
  122. <template slot-scope="scope">
  123. {{ scope.row.orderStatus === '0' ? $t("btOrder.status.wzf") : '' }}
  124. {{ scope.row.orderStatus === '1' ? $t("btOrder.status.yzf") : '' }}
  125. {{ scope.row.orderStatus === '2' ? $t("btOrder.status.yqx") : '' }}
  126. {{ scope.row.orderStatus === '3' ? $t("btOrder.status.scwc") : '' }}
  127. {{ scope.row.orderStatus === '4' ? $t("btOrder.status.yc") : '' }}
  128. {{ scope.row.orderStatus === '5' ? $t("btOrder.status.zrtk") : '' }}
  129. {{ scope.row.orderStatus === '6' ? $t("btOrder.status.qbwc") : '' }}
  130. </template>
  131. </el-table-column>
  132. <el-table-column
  133. :label="$t('table.operation')" align="center" column-key="operation" class-name="small-padding fixed-width"
  134. width="100px">
  135. <template slot-scope="{ row }">
  136. <i @click="orderDetail(row)" class="el-icon-view table-operation" :title="$t('btOrder.detail')"
  137. style="color: #2db7f5;"/>
  138. </template>
  139. </el-table-column>
  140. </el-table>
  141. <pagination :limit.sync="queryParams.size" :page.sync="queryParams.current"
  142. :total="Number(tableData.total)" @pagination="fetch" v-show="tableData.total > 0"/>
  143. <order-detail
  144. :dialog-visible="detailDialog.isVisible"
  145. :type="detailDialog.type"
  146. @close="orderDetailClose"
  147. @success="editSuccess"
  148. ref="orderDetail"/>
  149. </div>
  150. </template>
  151. <script>
  152. import Pagination from "@/components/Pagination";
  153. import elDragDialog from '@/directive/el-drag-dialog'
  154. import OrderEdit from "./components/Edit";
  155. import orderDetail from "./orderDetail";
  156. import orderApi from "@/api/Order.js";
  157. import OrderImport from "@/components/zuihou/Import"
  158. import {convertEnum} from '@/utils/utils'
  159. import {downloadFile, loadEnums, initDicts, initQueryParams} from '@/utils/commons'
  160. export default {
  161. name: "OrderManage",
  162. directives: {elDragDialog},
  163. components: {Pagination, OrderEdit, OrderImport, orderDetail},
  164. filters: {},
  165. data() {
  166. return {
  167. statusFilter: [{text: '未支付', value: '0'}, {text: '已支付', value: '1'}, {text: '已取消', value: '2'}, {
  168. text: '生产完成',
  169. value: '3'
  170. }, {
  171. text: '异常', value: '4'
  172. }, {text: '转入退款', value: '5'}],
  173. // :filters="[{ text: $t('common.status.valid'), value: '1' },{ text: $t('common.status.invalid'), value: '0' }]"
  174. // 编辑
  175. dialog: {
  176. isVisible: false,
  177. type: "add"
  178. },
  179. detailDialog: {
  180. isVisible: false,
  181. type: "orderDetail"
  182. },
  183. statusOptions: [{
  184. value: '0',
  185. label: '未支付'
  186. }, {
  187. value: '1',
  188. label: '已支付'
  189. }, {
  190. value: '2',
  191. label: '已取消'
  192. }, {
  193. value: '3',
  194. label: '生产完成'
  195. }, {
  196. value: '4',
  197. label: '异常'
  198. }, {
  199. value: '5',
  200. label: '转入退款'
  201. }],
  202. // 预览
  203. preview: {
  204. isVisible: false,
  205. context: ''
  206. },
  207. // 导入
  208. fileImport: {
  209. isVisible: false,
  210. type: "import",
  211. action: `${process.env.VUE_APP_BASE_API}/order/order/import`
  212. },
  213. tableKey: 0,
  214. queryParams: initQueryParams(),
  215. selection: [],
  216. loading: false,
  217. tableData: {
  218. total: 0
  219. },
  220. // 枚举
  221. enums: {},
  222. // 字典
  223. dicts: {}
  224. };
  225. },
  226. computed: {},
  227. watch: {},
  228. mounted() {
  229. this.fetch();
  230. // 初始化字典和枚举
  231. const enumList = [];
  232. const dictList = [];
  233. loadEnums(enumList, this.enums, 'order');
  234. initDicts(dictList, this.dicts);
  235. },
  236. methods: {
  237. editClose() {
  238. this.dialog.isVisible = false;
  239. },
  240. orderDetailClose() {
  241. this.detailDialog.isVisible = false;
  242. },
  243. editSuccess() {
  244. this.search();
  245. },
  246. onSelectChange(selection) {
  247. this.selection = selection;
  248. },
  249. search() {
  250. this.fetch({
  251. ...this.queryParams
  252. });
  253. },
  254. reset() {
  255. this.queryParams = initQueryParams();
  256. this.$refs.table.clearSort();
  257. this.$refs.table.clearFilter();
  258. this.search();
  259. },
  260. exportExcelPreview() {
  261. if (this.queryParams.timeRange) {
  262. this.queryParams.map.createTime_st = this.queryParams.timeRange[0];
  263. this.queryParams.map.createTime_ed = this.queryParams.timeRange[1];
  264. }
  265. this.queryParams.map.fileName = '导出数据';
  266. orderApi.preview(this.queryParams).then(response => {
  267. const res = response.data;
  268. this.preview.isVisible = true;
  269. this.preview.context = res.data;
  270. });
  271. },
  272. exportExcel() {
  273. if (this.queryParams.timeRange) {
  274. this.queryParams.map.createTime_st = this.queryParams.timeRange[0];
  275. this.queryParams.map.createTime_ed = this.queryParams.timeRange[1];
  276. }
  277. this.queryParams.map.fileName = '导出数据';
  278. orderApi.export(this.queryParams).then(response => {
  279. downloadFile(response);
  280. });
  281. },
  282. importExcel() {
  283. this.fileImport.type = "upload";
  284. this.fileImport.isVisible = true;
  285. this.$refs.import.setModel(false);
  286. },
  287. importSuccess() {
  288. this.search();
  289. },
  290. importClose() {
  291. this.fileImport.isVisible = false;
  292. },
  293. singleDelete(row) {
  294. this.$refs.table.clearSelection()
  295. this.$refs.table.toggleRowSelection(row, true);
  296. this.batchDelete();
  297. },
  298. batchDelete() {
  299. if (!this.selection.length) {
  300. this.$message({
  301. message: this.$t("tips.noDataSelected"),
  302. type: "warning"
  303. });
  304. return;
  305. }
  306. this.$confirm(this.$t("tips.confirmDelete"), this.$t("common.tips"), {
  307. confirmButtonText: this.$t("common.confirm"),
  308. cancelButtonText: this.$t("common.cancel"),
  309. type: "warning"
  310. })
  311. .then(() => {
  312. const ids = this.selection.map(u => u.id);
  313. this.delete(ids);
  314. })
  315. .catch(() => {
  316. this.clearSelections();
  317. });
  318. },
  319. clearSelections() {
  320. this.$refs.table.clearSelection();
  321. },
  322. delete(ids) {
  323. orderApi.delete({ids: ids}).then(response => {
  324. const res = response.data;
  325. if (res.isSuccess) {
  326. this.$message({
  327. message: this.$t("tips.deleteSuccess"),
  328. type: "success"
  329. });
  330. this.search();
  331. }
  332. });
  333. },
  334. add() {
  335. this.dialog.type = "add";
  336. this.dialog.isVisible = true;
  337. this.$refs.edit.setOrder({enums: this.enums, dicts: this.dicts});
  338. },
  339. orderDetail(row) {
  340. this.detailDialog.type = "orderDetail";
  341. this.detailDialog.isVisible = true;
  342. this.$refs.orderDetail.orderDetail(row['id']);
  343. },
  344. copy(row) {
  345. this.$refs.edit.setOrder({row, enums: this.enums, dicts: this.dicts});
  346. this.dialog.type = "copy";
  347. this.dialog.isVisible = true;
  348. },
  349. edit(row) {
  350. this.$refs.edit.setOrder({row, enums: this.enums, dicts: this.dicts});
  351. this.dialog.type = "edit";
  352. this.dialog.isVisible = true;
  353. },
  354. fetch(params = {}) {
  355. this.loading = true;
  356. if (this.queryParams.timeRange) {
  357. this.queryParams.map.createTime_st = this.queryParams.timeRange[0];
  358. this.queryParams.map.createTime_ed = this.queryParams.timeRange[1];
  359. }
  360. this.queryParams.current = params.current ? params.current : this.queryParams.current;
  361. this.queryParams.size = params.size ? params.size : this.queryParams.size;
  362. orderApi.page(this.queryParams).then(response => {
  363. const res = response.data;
  364. if (res.isSuccess) {
  365. this.tableData = res.data;
  366. }
  367. }).finally(() => this.loading = false);
  368. },
  369. sortChange(val) {
  370. this.queryParams.sort = val.prop;
  371. this.queryParams.order = val.order;
  372. if (this.queryParams.sort) {
  373. this.search();
  374. }
  375. },
  376. filterChange(filters) {
  377. for (const key in filters) {
  378. if (key.includes('.')) {
  379. const val = {};
  380. val[key.split('.')[1]] = filters[key][0];
  381. this.queryParams.model[key.split('.')[0]] = val;
  382. } else {
  383. this.queryParams.model[key] = filters[key][0]
  384. }
  385. }
  386. this.search()
  387. },
  388. cellClick(row, column) {
  389. if (column['columnKey'] === "operation") {
  390. return;
  391. }
  392. let flag = false;
  393. this.selection.forEach((item) => {
  394. if (item.id === row.id) {
  395. flag = true;
  396. this.$refs.table.toggleRowSelection(row);
  397. }
  398. })
  399. if (!flag) {
  400. this.$refs.table.toggleRowSelection(row, true);
  401. }
  402. },
  403. }
  404. };
  405. </script>
  406. <style lang="scss" scoped></style>