index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <a-card :bordered="false" style="margin-bottom: 10px" class="mb-2">
  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="goodsName">
  7. <a-input v-model:value="searchFormState.goodsName" placeholder="查询货品名称" allow-clear />
  8. </a-form-item>
  9. </a-col>
  10. <a-col :span="9">
  11. <a-form-item label="提货开始时间" name="confStartTime">
  12. <a-range-picker v-model:value="searchFormState.confStartTime" value-format="YYYY-MM-DD HH:mm" show-time allow-clear />
  13. </a-form-item>
  14. </a-col>
  15. <a-col :span="9">
  16. <a-form-item label="提货结束时间" name="confEndTime">
  17. <a-range-picker v-model:value="searchFormState.confEndTime" value-format="YYYY-MM-DD HH:mm" show-time allow-clear />
  18. </a-form-item>
  19. </a-col>
  20. </a-row>
  21. <a-row :gutter="24">
  22. <a-col :span="6">
  23. <a-form-item label="货品编码" name="goodsCode">
  24. <a-input v-model:value="searchFormState.goodsCode" placeholder="查询货品名称" allow-clear />
  25. </a-form-item>
  26. </a-col>
  27. <a-col :span="9"></a-col>
  28. <a-col :span="9">
  29. <a-button type="primary" @click="tableRef.refresh()">查询</a-button>
  30. <a-button style="margin: 0 8px" @click="reset">重置</a-button>
  31. <a-button type="primary" @click="addFormRef.onOpen()" v-if="hasPerm('goodsConfAdd')">
  32. <template #icon><plus-outlined /></template>
  33. 新增
  34. </a-button>
  35. </a-col>
  36. </a-row>
  37. </a-form>
  38. </a-card>
  39. <a-card :bordered="false">
  40. <s-table
  41. ref="tableRef"
  42. :columns="columns"
  43. :data="loadData"
  44. bordered
  45. :row-key="(record) => record.id"
  46. >
  47. <template #bodyCell="{ column, record, index }">
  48. <template v-if="column.dataIndex === 'serial'">
  49. {{ index + 1 }}
  50. </template>
  51. <template v-if="column.dataIndex === 'confWeight'">
  52. {{ record.confWeight / 1000 }}
  53. </template>
  54. <template v-if="column.dataIndex === 'usedWeight'">
  55. {{ record.usedWeight / 1000 }}
  56. </template>
  57. <template v-if="column.dataIndex === 'lastWeight'">
  58. {{ record.lastWeight / 1000 }}
  59. </template>
  60. <template v-if="column.dataIndex === 'action'">
  61. <a-space>
  62. <a @click="editFormRef.onOpen(record)" v-if="hasPerm('goodsConfEdit') && Number(record.usedWeight) == 0">编辑</a>
  63. <a-divider type="vertical" v-if="hasPerm(['goodsConfEdit', 'goodsConfDelete'], 'and') && Number(record.usedWeight) == 0" />
  64. <a-button type="link" danger size="small" v-if="hasPerm('goodsConfDelete')" @click="deleteConfig(record)">删除</a-button>
  65. <a-divider type="vertical" v-if="(hasPerm(['goodsConfEdit', 'goodsConfDelete'], 'or') && Number(record.usedWeight) == 0) && hasPerm('goodsConfWeight')" />
  66. <a @click="weightFormRef.onOpen(record)" v-if="hasPerm('goodsConfWeight')">重量</a>
  67. </a-space>
  68. </template>
  69. </template>
  70. </s-table>
  71. </a-card>
  72. <AddForm ref="addFormRef" @successful="tableRef.refresh()" />
  73. <EditForm ref="editFormRef" @successful="tableRef.refresh()" />
  74. <WeightForm ref="weightFormRef" @successful="tableRef.refresh()" />
  75. </template>
  76. <script setup name="goodsConf">
  77. import { cloneDeep } from 'lodash-es'
  78. import AddForm from './addForm.vue'
  79. import EditForm from './editForm.vue'
  80. import WeightForm from './weightForm.vue'
  81. import goodsConfApi from '@/api/biz/goodsConfApi'
  82. import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
  83. import {Modal} from 'ant-design-vue';
  84. import {createVNode} from 'vue';
  85. const searchFormState = ref({})
  86. const searchFormRef = ref()
  87. const tableRef = ref()
  88. const addFormRef = ref()
  89. const editFormRef = ref()
  90. const weightFormRef = ref()
  91. const submitLoading = ref(false)
  92. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  93. const columns = [
  94. {
  95. title: '序号',
  96. width: 50,
  97. dataIndex: 'serial',
  98. align:'center'
  99. },
  100. {
  101. title: '货品编码',
  102. width: 120,
  103. dataIndex: 'goodsCode',
  104. align:'center'
  105. },
  106. {
  107. title: '货品名称',
  108. dataIndex: 'goodsName',
  109. align:'center'
  110. },
  111. {
  112. title: '货品规格',
  113. width: 80,
  114. dataIndex: 'goodsModel',
  115. align:'center'
  116. },
  117. {
  118. title: '提货开始时间',
  119. width: 150,
  120. dataIndex: 'confStartTime',
  121. align:'center'
  122. },
  123. {
  124. title: '提货结束时间',
  125. width: 150,
  126. dataIndex: 'confEndTime',
  127. align:'center'
  128. },
  129. {
  130. title: '可提重量(吨)',
  131. width: 110,
  132. dataIndex: 'confWeight',
  133. align:'center'
  134. },
  135. {
  136. title: '已提重量(吨)',
  137. width: 110,
  138. dataIndex: 'usedWeight',
  139. align:'center'
  140. },
  141. {
  142. title: '剩余重量(吨)',
  143. width: 110,
  144. dataIndex: 'lastWeight',
  145. align:'center'
  146. },
  147. ]
  148. // 操作栏通过权限判断是否显示
  149. if (hasPerm(['goodsConfEdit', 'goodsConfDelete', 'goodsConfWeight'])) {
  150. columns.push({
  151. title: '操作',
  152. dataIndex: 'action',
  153. align: 'center',
  154. width: 200
  155. })
  156. }
  157. const selectedRowKeys = ref([])
  158. // 列表选择配置
  159. const options = {
  160. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  161. alert: {
  162. show: true,
  163. clear: () => {
  164. selectedRowKeys.value = ref([])
  165. }
  166. },
  167. rowSelection: {
  168. onChange: (selectedRowKey, selectedRows) => {
  169. selectedRowKeys.value = selectedRowKey
  170. }
  171. }
  172. }
  173. const loadData = (parameter) => {
  174. const searchFormParam = cloneDeep(searchFormState.value)
  175. // confStartTime范围查询条件重载
  176. if (searchFormParam.confStartTime) {
  177. searchFormParam.startConfStartTime = searchFormParam.confStartTime[0]+":00"
  178. searchFormParam.endConfStartTime = searchFormParam.confStartTime[1]+":00"
  179. delete searchFormParam.confStartTime
  180. }
  181. // confEndTime范围查询条件重载
  182. if (searchFormParam.confEndTime) {
  183. searchFormParam.startConfEndTime = searchFormParam.confEndTime[0]+":00"
  184. searchFormParam.endConfEndTime = searchFormParam.confEndTime[1]+":00"
  185. delete searchFormParam.confEndTime
  186. }
  187. return goodsConfApi.goodsConfPage(Object.assign(parameter, searchFormParam)).then((data) => {
  188. return data
  189. })
  190. }
  191. // 重置
  192. const reset = () => {
  193. searchFormRef.value.resetFields()
  194. tableRef.value.refresh(true)
  195. }
  196. // 删除
  197. const deleteConfig = (record) => {
  198. Modal.confirm({
  199. title: '确定删除该数据吗?',
  200. icon: createVNode(ExclamationCircleOutlined),
  201. content: '',
  202. onOk() {
  203. submitLoading.value = true
  204. let params = [
  205. {
  206. id: record.id
  207. }
  208. ]
  209. goodsConfApi
  210. .goodsConfDelete(params)
  211. .then(() => {
  212. tableRef.value.refresh(true)
  213. })
  214. .finally(() => {
  215. submitLoading.value = false
  216. })
  217. },
  218. onCancel() {}
  219. })
  220. }
  221. </script>