index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <a-card :bordered="false" v-if="indexShow">
  3. <a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
  4. <a-row :gutter="24">
  5. <a-col :span="6">
  6. <a-form-item label="企业编码" name="companyCode">
  7. <a-input v-model:value="searchFormState.companyCode" placeholder="请输入企业编码" allow-clear/>
  8. </a-form-item>
  9. </a-col>
  10. <a-col :span="6">
  11. <a-form-item label="企业名称" name="companyName">
  12. <a-input v-model:value="searchFormState.companyName" placeholder="请输入企业名称" allow-clear/>
  13. </a-form-item>
  14. </a-col>
  15. <a-col :span="6">
  16. <a-form-item label="账册类型" name="accountType">
  17. <a-select v-model:value="searchFormState.accountType" placeholder="请选择账册类型" :options="accountTypeOptions" show-search allow-clear option-filter-prop="label"/>
  18. </a-form-item>
  19. </a-col>
  20. <a-col :span="6" v-show="advanced">
  21. <a-form-item label="账册编号" name="accountCode">
  22. <a-input v-model:value="searchFormState.accountCode" placeholder="请输入账册编号" allow-clear/>
  23. </a-form-item>
  24. </a-col>
  25. <a-col :span="6" v-show="advanced">
  26. <a-form-item label="商品编码" name="commodityCode">
  27. <a-input v-model:value="searchFormState.commodityCode" placeholder="请输入商品编码" allow-clear/>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :span="6" v-show="advanced">
  31. <a-form-item label="商品名称" name="commodityName">
  32. <a-input v-model:value="searchFormState.commodityName" placeholder="请输入商品名称" allow-clear/>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :span="6" v-show="advanced">
  36. <a-form-item label="业务类型" name="businessType">
  37. <a-select v-model:value="searchFormState.businessType" placeholder="请选择业务类型" :options="businessTypeOptions" show-search allow-clear option-filter-prop="label"/>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :span="6" v-show="advanced">
  41. <a-form-item label="记账数量" name="accountNumber">
  42. <a-input-number v-model:value="searchFormState.accountNumber" placeholder="请输入记账数量" style="width: 100%" />
  43. </a-form-item>
  44. </a-col>
  45. <a-col :span="6" v-show="advanced">
  46. <a-form-item label="法定计量单位" name="measurementUnit">
  47. <a-select v-model:value="searchFormState.measurementUnit" placeholder="请选择法定计量单位" :options="measurementUnitOptions" show-search allow-clear option-filter-prop="label"/>
  48. </a-form-item>
  49. </a-col>
  50. <a-col :span="6" v-show="advanced">
  51. <a-form-item label="一线径予放行单号" name="frontlineRelesasNumber">
  52. <a-input v-model:value="searchFormState.frontlineRelesasNumber" placeholder="请输入一线径予放行单号" allow-clear/>
  53. </a-form-item>
  54. </a-col>
  55. <a-col :span="6" v-show="advanced">
  56. <a-form-item label="出/入库单号" name="warehouseNumber">
  57. <a-input v-model:value="searchFormState.warehouseNumber" placeholder="请输入出/入库单号" allow-clear/>
  58. </a-form-item>
  59. </a-col>
  60. <a-col :span="6" v-show="advanced">
  61. <a-form-item label="入库日期" name="warehouseTime">
  62. <a-range-picker v-model:value="searchFormState.warehouseTime" show-time allow-clear/>
  63. </a-form-item>
  64. </a-col>
  65. <a-col :span="6" v-show="advanced">
  66. <a-form-item label="记账日期" name="accountTime">
  67. <a-range-picker v-model:value="searchFormState.accountTime" show-time allow-clear/>
  68. </a-form-item>
  69. </a-col>
  70. <a-col :span="6">
  71. <a-button type="primary" @click="onSearch()">查询</a-button>
  72. <a-button style="margin: 0 8px" @click="reset">重置</a-button>
  73. <a @click="toggleAdvanced" style="margin-left: 8px">
  74. {{ advanced ? '收起' : '展开' }}
  75. <component :is="advanced ? 'up-outlined' : 'down-outlined'"/>
  76. </a>
  77. </a-col>
  78. </a-row>
  79. </a-form>
  80. <s-table
  81. ref="tableRef"
  82. :columns="columns"
  83. :data="loadData"
  84. :alert="options.alert.show"
  85. bordered
  86. :row-key="(record) => record.id"
  87. :tool-config="toolConfig"
  88. :row-selection="options.rowSelection"
  89. v-model:filterParam="filterParam"
  90. :scroll="{ x: 2000 }"
  91. >
  92. <template #operator class="table-operator">
  93. <a-space>
  94. <a-button type="primary" @click="onDetail()" v-if="hasPerm('qyFrontlineWarehouseAdd')">
  95. <template #icon><plus-outlined /></template>
  96. 新增
  97. </a-button>
  98. <xn-batch-delete
  99. v-if="hasPerm('qyFrontlineWarehouseDelete')"
  100. :selectedRowKeys="selectedRowKeys"
  101. @batchDelete="deleteBatchQyFrontlineWarehouse"
  102. />
  103. <a-button @click="onExport" v-if="hasPerm('qyFrontlineWarehouseBatchExport')">
  104. <template #icon><export-outlined /></template>
  105. 批量导出
  106. </a-button>
  107. </a-space>
  108. </template>
  109. <template #bodyCell="{ column, record }">
  110. <template v-if="column.dataIndex === 'accountType'">
  111. {{ $TOOL.dictTypeData('account_type', record.accountType) }}
  112. </template>
  113. <template v-if="column.dataIndex === 'businessType'">
  114. {{ $TOOL.dictTypeData('bussiness_type', record.businessType) }}
  115. </template>
  116. <template v-if="column.dataIndex === 'measurementUnit'">
  117. {{ $TOOL.dictTypeData('measurement unit', record.measurementUnit) }}
  118. </template>
  119. <template v-if="column.dataIndex === 'action'">
  120. <a-space>
  121. <a @click="onDetail(record, true)" v-if="hasPerm('qyFrontlineWarehouseView')">查看</a>
  122. <a-divider type="vertical" v-if="hasPerm('qyFrontlineWarehouseView') && hasPerm(['qyFrontlineWarehouseEdit', 'qyFrontlineWarehouseDelete'], 'or')" />
  123. <a @click="onDetail(record)" v-if="hasPerm('qyFrontlineWarehouseEdit')">编辑</a>
  124. <a-divider type="vertical" v-if="hasPerm(['qyFrontlineWarehouseEdit', 'qyFrontlineWarehouseDelete'], 'and')" />
  125. <a-popconfirm title="确定要删除吗?" @confirm="deleteQyFrontlineWarehouse(record)">
  126. <a-button type="link" danger size="small" v-if="hasPerm('qyFrontlineWarehouseDelete')">删除</a-button>
  127. </a-popconfirm>
  128. </a-space>
  129. </template>
  130. </template>
  131. </s-table>
  132. </a-card>
  133. <Detail v-else ref="detailRef" @onClose="indexShow = true" @successful="onSearch()" />
  134. </template>
  135. <script setup name="qyfrontlinewarehouse">
  136. import tool from '@/utils/tool'
  137. import { cloneDeep } from 'lodash-es'
  138. import Detail from './detail.vue'
  139. import qyFrontlineWarehouseApi from '@/api/biz/qyFrontlineWarehouseApi'
  140. import downloadUtil from "@/utils/downloadUtil";
  141. const { proxy } = getCurrentInstance()
  142. const searchFormState = ref({})
  143. const searchFormStateReal = ref({}) // 点击搜索后备份的查询参数
  144. const searchFormRef = ref()
  145. const tableRef = ref()
  146. const filterParam = ref({})
  147. const detailRef = ref()
  148. const indexShow = ref(true)
  149. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  150. // 查询区域显示更多控制
  151. const advanced = ref(false)
  152. const toggleAdvanced = () => {
  153. advanced.value = !advanced.value
  154. }
  155. const columns = [
  156. {
  157. title: '企业编码',
  158. dataIndex: 'companyCode',
  159. },
  160. {
  161. title: '企业名称',
  162. dataIndex: 'companyName',
  163. },
  164. {
  165. title: '账册类型',
  166. dataIndex: 'accountType',
  167. },
  168. {
  169. title: '账册编号',
  170. dataIndex: 'accountCode',
  171. },
  172. {
  173. title: '商品编码',
  174. dataIndex: 'commodityCode',
  175. },
  176. {
  177. title: '商品名称',
  178. dataIndex: 'commodityName',
  179. },
  180. {
  181. title: '业务类型',
  182. dataIndex: 'businessType',
  183. },
  184. {
  185. title: '记账数量',
  186. dataIndex: 'accountNumber',
  187. sorter: true,
  188. },
  189. {
  190. title: '法定计量单位',
  191. dataIndex: 'measurementUnit',
  192. },
  193. {
  194. title: '一线径予放行单号',
  195. dataIndex: 'frontlineRelesasNumber',
  196. },
  197. {
  198. title: '出/入库单号',
  199. dataIndex: 'warehouseNumber',
  200. },
  201. {
  202. title: '入库日期',
  203. dataIndex: 'warehouseTime',
  204. sorter: true,
  205. },
  206. {
  207. title: '记账日期',
  208. dataIndex: 'accountTime',
  209. sorter: true,
  210. },
  211. ]
  212. // 操作栏通过权限判断是否显示
  213. if (hasPerm(['qyFrontlineWarehouseEdit', 'qyFrontlineWarehouseDelete'])) {
  214. columns.push({
  215. title: '操作',
  216. dataIndex: 'action',
  217. align: 'center',
  218. width: 200,
  219. fixed: 'right',
  220. })
  221. }
  222. const selectedRowKeys = ref([])
  223. // 列表选择配置
  224. const options = {
  225. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  226. alert: {
  227. show: true,
  228. clear: () => {
  229. selectedRowKeys.value = ref([])
  230. }
  231. },
  232. rowSelection: {
  233. onChange: (selectedRowKey, selectedRows) => {
  234. selectedRowKeys.value = selectedRowKey
  235. }
  236. }
  237. }
  238. const loadData = (parameter) => {
  239. tableRef.value.clearSelected()
  240. // warehouseTime范围查询条件重载
  241. if (searchFormStateReal.value.warehouseTime) {
  242. searchFormStateReal.value.startWarehouseTime = searchFormStateReal.value.warehouseTime[0]
  243. searchFormStateReal.value.endWarehouseTime = searchFormStateReal.value.warehouseTime[1]
  244. delete searchFormStateReal.value.warehouseTime
  245. }
  246. // accountTime范围查询条件重载
  247. if (searchFormStateReal.value.accountTime) {
  248. searchFormStateReal.value.startAccountTime = searchFormStateReal.value.accountTime[0]
  249. searchFormStateReal.value.endAccountTime = searchFormStateReal.value.accountTime[1]
  250. delete searchFormStateReal.value.accountTime
  251. }
  252. return qyFrontlineWarehouseApi.qyFrontlineWarehousePage(Object.assign(parameter, searchFormStateReal.value)).then((data) => {
  253. return data
  254. })
  255. }
  256. // 搜索同时备份参数
  257. const onSearch = (parameter) => {
  258. searchFormStateReal.value = cloneDeep(searchFormState.value)
  259. nextTick(() => {
  260. tableRef.value.refresh(parameter)
  261. })
  262. }
  263. // 重置
  264. const reset = () => {
  265. searchFormRef.value.resetFields()
  266. onSearch(true)
  267. }
  268. // 删除
  269. const deleteQyFrontlineWarehouse = (record) => {
  270. let params = [
  271. {
  272. id: record.id
  273. }
  274. ]
  275. qyFrontlineWarehouseApi.qyFrontlineWarehouseDelete(params).then(() => {
  276. tableRef.value.refresh(true)
  277. })
  278. }
  279. // 批量删除
  280. const deleteBatchQyFrontlineWarehouse = (params) => {
  281. qyFrontlineWarehouseApi.qyFrontlineWarehouseDelete(params).then(() => {
  282. tableRef.value.clearRefreshSelected()
  283. })
  284. }
  285. // 批量导出
  286. const onExport = () => {
  287. const params = {
  288. ...filterParam.value
  289. }
  290. if (selectedRowKeys.value.length > 0) {
  291. params.ids = selectedRowKeys.value
  292. } else {
  293. Object.entries(searchFormStateReal.value).forEach(([key, value]) => {
  294. console.log(key)
  295. if (proxy.$util.isValue(value)) {
  296. params[key] = value
  297. }
  298. })
  299. }
  300. qyFrontlineWarehouseApi.qyFrontlineWarehouseExport(params).then((res) => {
  301. downloadUtil.resultDownload(res)
  302. tableRef.value.clearSelected()
  303. })
  304. }
  305. // 切换至表单
  306. const onDetail = (record = null, view) => {
  307. indexShow.value = false
  308. nextTick(() => {
  309. detailRef.value.onOpen(record, view)
  310. })
  311. }
  312. const accountTypeOptions = tool.dictList('account_type')
  313. const businessTypeOptions = tool.dictList('bussiness_type')
  314. const measurementUnitOptions = tool.dictList('measurement unit')
  315. </script>