tgTable.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <div class="tgTable">
  3. <!-- 数据表格 -->
  4. <ele-pro-table
  5. ref="table1"
  6. :columns="columns"
  7. height="calc(100vh-300px)"
  8. :pageSize="20"
  9. :datasource="datasource"
  10. :selection.sync="selection"
  11. cache-key="workOrderTable"
  12. >
  13. <template v-slot:toolbar v-if="$route.query.dashboard === '1' && type === '1'">
  14. <el-button type="primary" :disabled="!selection.length" @click="$emit('batch-receive', selection)">批量收货({{ selection.length }})</el-button>
  15. </template>
  16. <template v-slot:code="{ row }">
  17. <el-link type="primary" :underline="false" @click="details(row)">{{
  18. row.code
  19. }}</el-link>
  20. </template>
  21. <template v-slot:totalCount="{ row }">
  22. {{ row.totalCount }} {{ row.measuringUnit }}
  23. </template>
  24. <template v-slot:totalPackage="{ row }">
  25. {{ row.totalPackage }}
  26. </template>
  27. <template v-slot:totalWeight="{ row }">
  28. {{ row.totalWeight }} {{ row.weightUnit }}
  29. </template>
  30. <template v-slot:status="{ row }">
  31. <!-- <span :class="{ 'ele-text-danger': row.approvalStatus == 2 }">
  32. {{ statusFormatter(row.approvalStatus) }}
  33. </span> -->
  34. <span>
  35. {{ statusFormatter(row.status) }}
  36. </span>
  37. </template>
  38. <template v-slot:action="{ row }">
  39. <el-link
  40. type="primary"
  41. :underline="false"
  42. @click="depotInOut(row, type)"
  43. >
  44. {{ type == 1 ? '入库' : '出库' }}
  45. </el-link>
  46. </template>
  47. </ele-pro-table>
  48. <tgDetails ref="tgDetailsRefs"></tgDetails>
  49. </div>
  50. </template>
  51. <script>
  52. import { outputSceneState, sceneState } from '@/utils/dict/index';
  53. import storageApi from '@/api/warehouseManagement';
  54. import tgDetails from './tgDetails.vue';
  55. export default {
  56. props: {
  57. type: {
  58. type: String,
  59. default: ''
  60. }
  61. },
  62. components: {
  63. tgDetails
  64. },
  65. data() {
  66. return {
  67. outputSceneState,
  68. sceneState,
  69. loading: false,
  70. selection: [],
  71. statusOpt: [
  72. { label: '待处理', value: 0 },
  73. { label: '已处理', value: 1 },
  74. { label: '已撤销', value: 2 }
  75. ]
  76. };
  77. },
  78. computed: {
  79. // 表格列配置
  80. columns() {
  81. return [
  82. ...(this.$route.query.dashboard === '1' && this.type === '1' ? [{ type:'selection',width:55,align:'center',selectable:(row) => row.status === 0 }] : []),
  83. {
  84. columnKey: 'index',
  85. label: '序号',
  86. type: 'index',
  87. width: 55,
  88. align: 'center',
  89. showOverflowTooltip: true,
  90. fixed: 'left'
  91. },
  92. {
  93. prop: 'code',
  94. slot: 'code',
  95. label: '编码',
  96. showOverflowTooltip: true,
  97. align: 'center',
  98. minWidth: 100
  99. },
  100. {
  101. prop: 'categoryNames',
  102. label: '名称',
  103. showOverflowTooltip: true,
  104. align: 'center'
  105. },
  106. // { label: '型号', prop: 'modelType', width: '150' },
  107. // { label: '规格', prop: 'specification', width: '150' },
  108. // { label: '牌号', prop: 'brandNum', width: '100' },
  109. {
  110. prop: 'sourceType',
  111. label: '出入库类型',
  112. align: 'center',
  113. formatter: (row, column, cellValue) => {
  114. console.log(row);
  115. switch (this.type) {
  116. case '1':
  117. // 入库
  118. return this.sceneState.filter(
  119. (item) => item.code == row.sourceType
  120. )[0].label;
  121. case '2':
  122. // 出库
  123. return this.outputSceneState.filter(
  124. (item) => item.code == row.sourceType
  125. )[0].label;
  126. }
  127. }
  128. },
  129. {
  130. prop: 'approvalUserName',
  131. label: '审核人',
  132. align: 'center'
  133. },
  134. {
  135. prop: 'createUserName',
  136. label: '申请人',
  137. align: 'center'
  138. },
  139. {
  140. prop: 'createTime',
  141. label: '创建时间',
  142. align: 'center',
  143. showOverflowTooltip: true,
  144. minWidth: 110
  145. },
  146. {
  147. slot: 'status',
  148. label: '状态',
  149. align: 'center'
  150. },
  151. {
  152. columnKey: 'action',
  153. label: '操作',
  154. width: 120,
  155. align: 'center',
  156. resizable: false,
  157. fixed: 'right',
  158. slot: 'action',
  159. showOverflowTooltip: true
  160. }
  161. ];
  162. }
  163. },
  164. created() {},
  165. methods: {
  166. statusFormatter(status) {
  167. const obj = this.statusOpt.find((i) => i.value == status);
  168. return obj && obj.label;
  169. },
  170. /* 表格数据源 */
  171. datasource({ page, limit, where }) {
  172. return storageApi.getinboundRequestsList({
  173. pageNum: page,
  174. size: limit,
  175. type: this.type,
  176. ...where
  177. });
  178. },
  179. details(row) {
  180. this.$refs.tgDetailsRefs.open(row);
  181. },
  182. depotInOut(row, type) {
  183. console.log(row, type);
  184. if (type == 1) {
  185. this.$router.push({
  186. path: '/warehouseManagement/stockManagement/add',
  187. query: {
  188. ...(this.$route.query.dashboard === '1' ? { ...this.$route.query,dashboard:'1' } : {}),
  189. code: row.code,
  190. inId: row.id,
  191. type: '1',
  192. sourceType: row.sourceType,
  193. name: 'inboundRequests'
  194. }
  195. });
  196. } else {
  197. this.$router.push({
  198. path: '/warehouseManagement/outgoingManagement/add',
  199. query: {
  200. ...(this.$route.query.dashboard === '1' ? { ...this.$route.query,dashboard:'1' } : {}),
  201. code: row.code,
  202. id: row.id,
  203. type: '2',
  204. sourceType: row.sourceType,
  205. fromId: row.createUserId,
  206. }
  207. });
  208. }
  209. },
  210. /* 刷新表格 */
  211. reload(where) {
  212. this.selection = [];
  213. this.$nextTick(() => {
  214. if (this.$refs.table1) {
  215. this.$refs.table1.reload({ page: 1, where });
  216. }
  217. });
  218. }
  219. }
  220. };
  221. </script>
  222. <style lang="scss" scoped>
  223. .tgTable {
  224. height: 100%;
  225. box-sizing: border-box;
  226. display: flex;
  227. flex-direction: column;
  228. .ele-pro-table {
  229. flex: 1;
  230. display: flex;
  231. flex-direction: column;
  232. .el-table {
  233. flex: 1;
  234. // display: flex;
  235. // flex-direction: column;
  236. // .el-table__body-wrapper {
  237. // flex: 1;
  238. // }
  239. }
  240. }
  241. }
  242. </style>