OutStockApplyWarehouse.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <script setup lang="ts">
  2. import type {FormInstance} from 'element-plus'
  3. import {ElMessage, ElMessageBox} from 'element-plus'
  4. import {useRouter} from 'vue-router'
  5. import {GlobalStore} from '@/stores'
  6. import {dayJs} from '@/utils/common'
  7. import {Edit, View, Delete} from '@element-plus/icons-vue'
  8. import {nextTick, reactive, ref} from 'vue'
  9. import TableBase from '@/components/TableBase/index.vue'
  10. import type {ColumnProps} from '@/components/TableBase/interface'
  11. import {stockOutExcelBatch, Storehouse_StockOut_Apply_Del, Storehouse_StockOut_Warehouse_List} from '@/api/storehouse'
  12. import {depotHooks} from '@/hooks/useDepot'
  13. import OutStorageWarehouse from './modules/OutStorageWarehouse.vue'
  14. import OutStorageEdit from './modules/OutStorageEdit.vue'
  15. import {paymentMethodOptions} from '@/hooks/useTablePublic'
  16. const router = useRouter()
  17. const globalStore = GlobalStore()
  18. const TableRef = ref<InstanceType<typeof TableBase> | null>(null)
  19. const multipleSelection = ref<any[]>([])
  20. const columns: ColumnProps[] = [
  21. {type: 'selection', width: '44px', fixed: 'left'},
  22. {type: 'index', label: '序号', width: 80},
  23. {prop: 'T_number', label: '出库单号'},
  24. {prop: 'T_application_date', label: '申请日期'},
  25. {prop: 'T_state_str', label: '状态', name: 'T_state_str'},
  26. {prop: 'T_company_name', label: '公司名称'},
  27. {prop: 'T_payment_method', label: '付款方式', name: 'T_payment_method', width: 150},
  28. {prop: 'T_receive_name', label: '领取人'},
  29. {prop: 'T_depot_name', label: '出库仓库'},
  30. {prop: 'T_date', label: '出库日期'},
  31. {prop: 'T_project', label: '关联项目'},
  32. {prop: 'operation', label: '操作', width: 250, fixed: 'right', align: 'left '}
  33. ]
  34. // 搜索
  35. const stateOptions = reactive([
  36. {name: '待审批', id: 1},
  37. {name: '财务通过', id: 2},
  38. {name: '财务驳回', id: 3},
  39. {name: '总经理通过', id: 4},
  40. {name: '总经理驳回', id: 5},
  41. {name: '已出库', id: 6},
  42. ])
  43. /**
  44. * 查看详情
  45. */
  46. const preview = (number: string) => {
  47. router.push({name: 'OutStockDetail', params: {number}})
  48. }
  49. const OutStorageRef = ref()
  50. const OutStorageEditRef = ref()
  51. const getFormattedDate = (date: string | null | undefined) => {
  52. return date || dayJs().format('YYYY-MM-DD')
  53. }
  54. /**
  55. * 编辑
  56. */
  57. const previewEdit = (row: any) => {
  58. OutStorageEditRef.value?.openDrawer(true) // 传递true表示从仓库页面打开
  59. OutStorageEditRef.value?.getStorehouseContractGet(row.T_number)
  60. for (let key in OutStorageEditRef.value?.form) {
  61. if (row.hasOwnProperty(key)) OutStorageEditRef.value.form[key] = row[key];
  62. }
  63. }
  64. /**
  65. * 出库操作
  66. */
  67. const previewOutStock = (row: any) => {
  68. OutStorageRef.value?.openDrawer()
  69. OutStorageRef.value?.getStorehouseContractGet(row.T_number)
  70. for (let key in OutStorageRef.value?.form) {
  71. // if (row.hasOwnProperty(key)) OutStorageRef.value.form[key] = row[key];
  72. if (row.hasOwnProperty(key)) {
  73. OutStorageRef.value.form[key] = key === 'T_date'
  74. ? getFormattedDate(row[key])
  75. : row[key]
  76. }
  77. }
  78. }
  79. // 搜索
  80. const T_date = ref<string[]>([])
  81. const initParam = reactive({
  82. User_tokey: globalStore.GET_User_tokey,
  83. T_end_date: '',
  84. T_start_date: '',
  85. T_depot_id: '',
  86. T_name: '',
  87. T_state: ''
  88. })
  89. const searchHandle = () => {
  90. initParam.T_end_date = T_date.value ? T_date.value[1] : ''
  91. initParam.T_start_date = T_date.value ? T_date.value[0] : ''
  92. TableRef.value?.searchTable()
  93. }
  94. /**
  95. * 重置表单
  96. */
  97. const resetForm = (formEl: FormInstance | undefined) => {
  98. if (!formEl) return
  99. formEl.resetFields()
  100. }
  101. /**
  102. * 删除
  103. */
  104. const deleteFun = (row: any) => {
  105. ElMessageBox.confirm(
  106. '删除操作,是否立即删除?',
  107. '删除',
  108. {
  109. confirmButtonText: '立即删除',
  110. cancelButtonText: '取消',
  111. type: 'warning',
  112. center: true,
  113. }
  114. ).then(async () => {
  115. const result: any = await Storehouse_StockOut_Apply_Del({T_number: row})
  116. if (result.Code == 200) {
  117. ElMessage.success('删除成功')
  118. TableRef.value?.searchTable()
  119. }
  120. }).catch(() => {
  121. })
  122. }
  123. // 拿到仓库列表
  124. const {options} = depotHooks()
  125. // 保存选中的数据id,row-key就是要指定一个key标识这一行的数据
  126. const getRowKey = (row: any) => {
  127. return row.T_number
  128. }
  129. const stockOutExcelFun = async () => {
  130. if (multipleSelection.value.length === 0) {
  131. ElMessage.warning('请选择出库单!!!')
  132. return
  133. }
  134. let T_number_list = ''
  135. for (let item of multipleSelection.value) {
  136. T_number_list += item.T_number + '|'
  137. }
  138. const result: any = await stockOutExcelBatch({T_number_list: T_number_list})
  139. if (result.Code === 200) {
  140. window.open(result.Data)
  141. }
  142. nextTick(() => {
  143. multipleSelection.value = []
  144. TableRef.value?.clearSelection()
  145. })
  146. }
  147. const handleSelectionChange = (val: any[]) => {
  148. multipleSelection.value = val
  149. console.log(multipleSelection.value)
  150. }
  151. </script>
  152. <template>
  153. <div class="out-stock">
  154. <TableBase ref="TableRef" :columns="columns" :requestApi="Storehouse_StockOut_Warehouse_List"
  155. :initParam="initParam"
  156. :getRowKey="getRowKey"
  157. :selection-change="handleSelectionChange"
  158. >
  159. <template #table-header>
  160. <div class="input-suffix">
  161. <el-row :gutter="20" style="margin-bottom: 0">
  162. <el-col :xl="5" :lg="5" :md="5" style="display: flex">
  163. <span class="inline-flex items-center">出库编号:</span>
  164. <el-input
  165. v-model="initParam.T_name"
  166. class="w-50 m-2"
  167. type="text"
  168. placeholder="出库编号搜索"
  169. clearable
  170. @change="searchHandle"
  171. />
  172. </el-col>
  173. <el-col :xl="5" :lg="5" :md="5" style="display: flex">
  174. <span class="inline-flex items-center">状态:</span>
  175. <el-select v-model="initParam.T_state" class="w-50 m-2" clearable placeholder="请选择状态~">
  176. <el-option v-for="item in stateOptions" :key="item.id" :label="item.name"
  177. :value="item.id"/>
  178. </el-select>
  179. <el-button type="primary" @click="searchHandle">搜索</el-button>
  180. </el-col>
  181. <el-col :xl="14" :lg="14" :md="14" class="btn">
  182. <el-button type="primary" @click="router.push({
  183. path: '/receiveOutStockApply',
  184. query: { fromWarehouse: '1' }
  185. })">出库申请</el-button>
  186. <el-button type="success" icon="Download" @click="stockOutExcelFun">导出excel</el-button>
  187. </el-col>
  188. </el-row>
  189. </div>
  190. </template>
  191. <template #T_payment_method="{ row }">
  192. <el-text type="info">
  193. {{ paymentMethodOptions.find((option) => option.id === row.T_payment_method)?.name || '' }}
  194. </el-text>
  195. </template>
  196. <template #T_state_str="{ row }">
  197. <el-text v-if="row.T_state_str === '待审批'" type="warning"> 待审批</el-text>
  198. <el-text v-if="row.T_state_str === '财务通过'" type="primary"> 财务通过</el-text>
  199. <el-text v-if="row.T_state_str === '财务驳回'" type="danger"> 财务驳回</el-text>
  200. <el-text v-if="row.T_state_str === '总经理通过'" type="primary"> 总经理通过</el-text>
  201. <el-text v-if="row.T_state_str === '总经理驳回'" type="danger"> 总经理驳回</el-text>
  202. <el-text v-if="row.T_state_str === '已出库'" type="success"> 已出库</el-text>
  203. </template>
  204. <template #right="{ row }">
  205. <el-button link type="success" size="small" :icon="View" @click="preview(row.T_number)">详情</el-button>
  206. <el-button link type="primary" size="small" :icon="Edit" @click="previewEdit(row)"
  207. :disabled="row.T_state === 6"
  208. >编辑</el-button>
  209. <el-button link type="warning" size="small" :icon="Edit" @click="previewOutStock(row)"
  210. :disabled="row.T_state !== 4 "
  211. >出库</el-button>
  212. <el-button link type="danger" size="small" :icon="Delete" @click="deleteFun(row.T_number)"
  213. :disabled="row.T_state === 6"
  214. >删除</el-button>
  215. </template>
  216. </TableBase>
  217. <OutStorageWarehouse ref="OutStorageRef" :options="options" @onUpdateList="searchHandle"/>
  218. <OutStorageEdit ref="OutStorageEditRef" :options="options" @onUpdateList="searchHandle"/>
  219. </div>
  220. </template>
  221. <style scoped lang="scss">
  222. @import '@/styles/var.scss';
  223. .out-stock {
  224. @include f-direction;
  225. :deep(.el-drawer__header) {
  226. margin-bottom: 0;
  227. }
  228. .input-suffix {
  229. width: 100%;
  230. .inline-flex {
  231. white-space: nowrap;
  232. }
  233. }
  234. .btn {
  235. display: flex;
  236. justify-content: right;
  237. .el-button {
  238. padding: 0 20px;
  239. }
  240. }
  241. }
  242. </style>