index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
  4. <el-form-item label="大队" prop="brigadeId">
  5. <el-select v-model="queryParams.brigadeId" placeholder="请选择大队" filterable clearable style="width: 200px">
  6. <el-option v-for="item in brigadeOptions" :key="item.value" :label="item.label" :value="item.value" />
  7. </el-select>
  8. </el-form-item>
  9. <el-form-item label="统计日期" prop="statDate">
  10. <el-date-picker clearable v-model="queryParams.statDate" type="date" placeholder="选择统计日期"
  11. value-format="YYYY-MM-DD" style="width: 200px" />
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  15. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-row :gutter="10" class="mb8">
  19. <el-col :span="1.5">
  20. <el-button type="primary" plain icon="Plus" @click="handleAdd"
  21. v-hasPermi="['dailyLuggageInspectionScheduleByTime:dailyLuggageInspectionScheduleByTime:add']">新增</el-button>
  22. </el-col>
  23. <el-col :span="1.5">
  24. <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
  25. v-hasPermi="['dailyLuggageInspectionScheduleByTime:dailyLuggageInspectionScheduleByTime:remove']">删除</el-button>
  26. </el-col>
  27. <el-col :span="1.5">
  28. <el-button type="warning" plain icon="Download" @click="handleExport"
  29. v-hasPermi="['dailyLuggageInspectionScheduleByTime:dailyLuggageInspectionScheduleByTime:export']">导出</el-button>
  30. </el-col>
  31. <el-col :span="1.5">
  32. <el-button type="info" plain icon="Upload" @click="handleImport"
  33. v-hasPermi="['dailyLuggageInspectionScheduleByTime:dailyLuggageInspectionScheduleByTime:import']">导入</el-button>
  34. </el-col>
  35. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  36. </el-row>
  37. <el-table v-loading="loading" :data="dailyLuggageInspectionScheduleByTimeList"
  38. @selection-change="handleSelectionChange">
  39. <el-table-column type="selection" width="55" align="center" />
  40. <el-table-column label="统计日期" align="center" prop="statDate" />
  41. <el-table-column label="当班大队" align="center" prop="brigadeName" />
  42. <el-table-column label="时间段" align="center" prop="timePeriod" />
  43. <el-table-column label="备注" align="center" prop="remark" />
  44. <el-table-column label="T1行检箱包数" align="center" prop="t1WalkBagCount" />
  45. <el-table-column label="T1行检查堵数" align="center" prop="t1WalkBlockedCount" />
  46. <el-table-column label="T2行检箱包数" align="center" prop="t2WalkBagCount" />
  47. <el-table-column label="T2行检查堵数" align="center" prop="t2WalkBlockedCount" />
  48. <el-table-column label="T1旅检箱包数" align="center" prop="t1TravelBagCount" />
  49. <el-table-column label="T1旅检查堵数" align="center" prop="t1TravelBlockedCount" />
  50. <el-table-column label="T2旅检箱包数" align="center" prop="t2TravelBagCount" />
  51. <el-table-column label="T2旅检查堵数" align="center" prop="t2TravelBlockedCount" />
  52. <el-table-column label="过检行李数" align="center" prop="totalLuggageCount" />
  53. <el-table-column label="时段查堵件数" align="center" prop="totalBlockedCount" />
  54. <el-table-column label="查堵万分率" align="center" prop="blockedRate" />
  55. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="140">
  56. <template #default="scope">
  57. <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
  58. v-hasPermi="['dailyLuggageInspectionScheduleByTime:dailyLuggageInspectionScheduleByTime:edit']">修改</el-button>
  59. <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
  60. v-hasPermi="['dailyLuggageInspectionScheduleByTime:dailyLuggageInspectionScheduleByTime:remove']">删除</el-button>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
  65. v-model:limit="queryParams.pageSize" @pagination="getList" />
  66. <el-dialog :title="title" v-model="open" width="1000px" append-to-body @closed="reset" destroy-on-close>
  67. <el-form ref="dailyLuggageInspectionScheduleByTimeRef" :model="form" :rules="rules" label-width="250px">
  68. <el-row :gutter="20">
  69. <el-col :span="12">
  70. <el-form-item label="统计日期" prop="statDate">
  71. <el-date-picker v-model="form.statDate" type="date" placeholder="选择统计日期" value-format="YYYY-MM-DD"
  72. style="width: 100%" />
  73. </el-form-item>
  74. </el-col>
  75. <el-col :span="12">
  76. <el-form-item label="当班大队" prop="brigadeId">
  77. <el-select v-model="form.brigadeId" placeholder="请选择当班大队" filterable style="width: 100%">
  78. <el-option v-for="item in brigadeOptions" :key="item.value" :label="item.label" :value="item.value" />
  79. </el-select>
  80. </el-form-item>
  81. </el-col>
  82. </el-row>
  83. <el-row :gutter="20">
  84. <el-col :span="12">
  85. <el-form-item label="时间段" prop="timePeriod">
  86. <el-select v-model="form.timePeriod" placeholder="请选择时间段" filterable style="width: 100%">
  87. <el-option v-for="dict in blocked_time_period" :key="dict.value" :label="dict.label"
  88. :value="dict.value" />
  89. </el-select>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="12">
  93. <el-form-item label="备注" prop="remark">
  94. <el-input v-model="form.remark" placeholder="请输入备注" style="width: 100%" />
  95. </el-form-item>
  96. </el-col>
  97. </el-row>
  98. <el-row :gutter="20">
  99. <el-col :span="12">
  100. <el-form-item label="T1行检箱包数" prop="t1WalkBagCount">
  101. <el-input-number v-model="form.t1WalkBagCount" :min="0" :precision="0" style="width: 100%" />
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="12">
  105. <el-form-item label="T1行检查堵数" prop="t1WalkBlockedCount">
  106. <el-input-number v-model="form.t1WalkBlockedCount" :min="0" :precision="0" style="width: 100%" />
  107. </el-form-item>
  108. </el-col>
  109. </el-row>
  110. <el-row :gutter="20">
  111. <el-col :span="12">
  112. <el-form-item label="T2行检箱包数(国内+国际)" prop="t2WalkBagCount">
  113. <el-input-number v-model="form.t2WalkBagCount" :min="0" :precision="0" style="width: 100%" />
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="12">
  117. <el-form-item label="T2行检查堵数" prop="t2WalkBlockedCount">
  118. <el-input-number v-model="form.t2WalkBlockedCount" :min="0" :precision="0" style="width: 100%" />
  119. </el-form-item>
  120. </el-col>
  121. </el-row>
  122. <el-row :gutter="20">
  123. <el-col :span="12">
  124. <el-form-item label="T1旅检箱包数(国内+国际+中转)" prop="t1TravelBagCount">
  125. <el-input-number v-model="form.t1TravelBagCount" :min="0" :precision="0" style="width: 100%" />
  126. </el-form-item>
  127. </el-col>
  128. <el-col :span="12">
  129. <el-form-item label="T1旅检查堵数" prop="t1TravelBlockedCount">
  130. <el-input-number v-model="form.t1TravelBlockedCount" :min="0" :precision="0" style="width: 100%" />
  131. </el-form-item>
  132. </el-col>
  133. </el-row>
  134. <el-row :gutter="20">
  135. <el-col :span="12">
  136. <el-form-item label="T2旅检箱包数" prop="t2TravelBagCount">
  137. <el-input-number v-model="form.t2TravelBagCount" :min="0" :precision="0" style="width: 100%" />
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="12">
  141. <el-form-item label="T2旅检查堵数" prop="t2TravelBlockedCount">
  142. <el-input-number v-model="form.t2TravelBlockedCount" :min="0" :precision="0" style="width: 100%" />
  143. </el-form-item>
  144. </el-col>
  145. </el-row>
  146. </el-form>
  147. <template #footer>
  148. <div class="dialog-footer">
  149. <el-button type="primary" @click="submitForm">确 定</el-button>
  150. <el-button @click="cancel">取 消</el-button>
  151. </div>
  152. </template>
  153. </el-dialog>
  154. <el-dialog title="导入" v-model="upload.open" width="500px" append-to-body>
  155. <el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url"
  156. :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess"
  157. :auto-upload="false" drag>
  158. <el-icon class="el-icon--upload"><upload-filled /></el-icon>
  159. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  160. <template #tip>
  161. <div class="el-upload__tip text-center">
  162. <span>仅允许导入xls、xlsx格式文件。</span>
  163. <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
  164. @click="importTemplate">下载模板</el-link>
  165. </div>
  166. </template>
  167. </el-upload>
  168. <template #footer>
  169. <div class="dialog-footer">
  170. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  171. <el-button @click="upload.open = false">取 消</el-button>
  172. </div>
  173. </template>
  174. </el-dialog>
  175. </div>
  176. </template>
  177. <script setup>
  178. import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
  179. import { listDailyLuggageInspectionScheduleByTime, getDailyLuggageInspectionScheduleByTime, delDailyLuggageInspectionScheduleByTime, addDailyLuggageInspectionScheduleByTime, updateDailyLuggageInspectionScheduleByTime, exportDailyLuggageInspectionScheduleByTime, downloadTemplate } from '@/api/blockingData/dailyLuggageInspectionScheduleByTime'
  180. import { listDept } from '@/api/system/dept'
  181. import { useDict } from '@/utils/dict'
  182. import { getToken } from '@/utils/auth'
  183. import { UploadFilled } from '@element-plus/icons-vue'
  184. const { proxy } = getCurrentInstance()
  185. const { blocked_time_period } = useDict('blocked_time_period')
  186. const loading = ref(true)
  187. const ids = ref([])
  188. const single = ref(true)
  189. const multiple = ref(true)
  190. const showSearch = ref(true)
  191. const total = ref(0)
  192. const dailyLuggageInspectionScheduleByTimeList = ref([])
  193. const title = ref('')
  194. const open = ref(false)
  195. const upload = reactive({
  196. open: false,
  197. isUploading: false,
  198. headers: { Authorization: 'Bearer ' + getToken() },
  199. url: import.meta.env.VITE_APP_BASE_API + '/blocked/pieceDaily/importData'
  200. })
  201. const queryParams = reactive({
  202. pageNum: 1,
  203. pageSize: 10,
  204. brigadeId: null,
  205. statDate: null
  206. })
  207. const form = reactive({})
  208. const rules = {
  209. statDate: [{ required: true, message: '统计日期不能为空', trigger: 'change' }],
  210. brigadeId: [{ required: true, message: '当班大队不能为空', trigger: 'change' }],
  211. timePeriod: [{ required: true, message: '时间段不能为空', trigger: 'change' }],
  212. t1WalkBagCount: [
  213. { required: true, message: 'T1行检箱包数不能为空', trigger: 'blur' },
  214. { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
  215. ],
  216. t1WalkBlockedCount: [
  217. { required: true, message: 'T1行检查堵数不能为空', trigger: 'blur' },
  218. { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
  219. ],
  220. t2WalkBagCount: [
  221. { required: true, message: 'T2行检箱包数不能为空', trigger: 'blur' },
  222. { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
  223. ],
  224. t2WalkBlockedCount: [
  225. { required: true, message: 'T2行检查堵数不能为空', trigger: 'blur' },
  226. { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
  227. ],
  228. t1TravelBagCount: [
  229. { required: true, message: 'T1旅检箱包数不能为空', trigger: 'blur' },
  230. { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
  231. ],
  232. t1TravelBlockedCount: [
  233. { required: true, message: 'T1旅检查堵数不能为空', trigger: 'blur' },
  234. { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
  235. ],
  236. t2TravelBagCount: [
  237. { required: true, message: 'T2旅检箱包数不能为空', trigger: 'blur' },
  238. { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
  239. ],
  240. t2TravelBlockedCount: [
  241. { required: true, message: 'T2旅检查堵数不能为空', trigger: 'blur' },
  242. { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
  243. ]
  244. // remark 不设置必填校验
  245. }
  246. const brigadeOptions = ref([])
  247. function getList() {
  248. loading.value = true
  249. listDailyLuggageInspectionScheduleByTime(queryParams).then(response => {
  250. dailyLuggageInspectionScheduleByTimeList.value = response.rows
  251. total.value = response.total
  252. loading.value = false
  253. })
  254. }
  255. function getDeptList() {
  256. listDept({}).then(response => {
  257. const deptList = response.data || []
  258. brigadeOptions.value = deptList.filter(item => item.deptType === 'BRIGADE' && [311, 314, 315].includes(item.deptId)).map(item => ({
  259. value: item.deptId,
  260. label: item.deptName
  261. }))
  262. })
  263. }
  264. function cancel() {
  265. open.value = false
  266. reset()
  267. }
  268. function reset() {
  269. Object.assign(form, {
  270. id: null,
  271. statDate: null,
  272. brigadeId: null,
  273. timePeriod: null,
  274. remark: null,
  275. t1WalkBagCount: null,
  276. t1WalkBlockedCount: null,
  277. t2WalkBagCount: null,
  278. t2WalkBlockedCount: null,
  279. t1TravelBagCount: null,
  280. t1TravelBlockedCount: null,
  281. t2TravelBagCount: null,
  282. t2TravelBlockedCount: null,
  283. totalLuggageCount: 0,
  284. totalBlockedCount: 0,
  285. blockedRate: 0
  286. })
  287. proxy.resetForm('dailyLuggageInspectionScheduleByTimeRef')
  288. }
  289. function handleQuery() {
  290. queryParams.pageNum = 1
  291. getList()
  292. }
  293. function resetQuery() {
  294. proxy.resetForm('queryRef')
  295. handleQuery()
  296. }
  297. function handleSelectionChange(selection) {
  298. ids.value = selection.map(item => item.id)
  299. single.value = selection.length !== 1
  300. multiple.value = !selection.length
  301. }
  302. function handleAdd() {
  303. reset()
  304. // 设置默认当前日期
  305. form.statDate = new Date().toISOString().split('T')[0]
  306. open.value = true
  307. title.value = '添加每日各时段查堵行李'
  308. }
  309. function handleUpdate(row) {
  310. reset()
  311. const id = row.id || ids.value[0]
  312. getDailyLuggageInspectionScheduleByTime(id).then(response => {
  313. Object.assign(form, response.data)
  314. open.value = true
  315. title.value = '修改每日各时段查堵行李'
  316. })
  317. }
  318. function submitForm() {
  319. proxy.$refs.dailyLuggageInspectionScheduleByTimeRef.validate(valid => {
  320. if (valid) {
  321. // 获取brigadeName
  322. const selectedBrigade = brigadeOptions.value.find(item => item.value === form.brigadeId)
  323. if (selectedBrigade) {
  324. form.brigadeName = selectedBrigade.label
  325. }
  326. if (form.id != null) {
  327. updateDailyLuggageInspectionScheduleByTime(form).then(response => {
  328. proxy.$modal.msgSuccess('修改成功')
  329. open.value = false
  330. reset()
  331. getList()
  332. })
  333. } else {
  334. addDailyLuggageInspectionScheduleByTime(form).then(response => {
  335. proxy.$modal.msgSuccess('新增成功')
  336. open.value = false
  337. reset()
  338. getList()
  339. })
  340. }
  341. }
  342. })
  343. }
  344. function handleDelete(row) {
  345. const id = row.id || ids.value
  346. proxy.$modal.confirm('是否确认删除每日各时段查堵行李编号为"' + id + '"的数据项?').then(function () {
  347. return delDailyLuggageInspectionScheduleByTime(id)
  348. }).then(() => {
  349. getList()
  350. proxy.$modal.msgSuccess('删除成功')
  351. }).catch(() => { })
  352. }
  353. function handleExport() {
  354. proxy.download('/blocked/pieceDaily/export', {
  355. ...queryParams
  356. }, `每日各时段查堵行李_${new Date().getTime()}.xlsx`)
  357. }
  358. function handleImport() {
  359. upload.open = true
  360. }
  361. /** 下载模板操作 */
  362. function importTemplate() {
  363. proxy.download('blocked/pieceDaily/importTemplate', {}, `每日各时段查堵行李模板_${new Date().getTime()}.xlsx`)
  364. }
  365. /** 文件上传中处理 */
  366. const handleFileUploadProgress = (event, file, fileList) => {
  367. upload.isUploading = true
  368. }
  369. /** 文件上传成功处理 */
  370. const handleFileSuccess = (response, file, fileList) => {
  371. upload.open = false
  372. upload.isUploading = false
  373. proxy.$refs.uploadRef.handleRemove(file)
  374. proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true })
  375. getList()
  376. }
  377. /** 提交上传文件 */
  378. function submitFileForm() {
  379. proxy.$refs.uploadRef.submit()
  380. }
  381. onMounted(() => {
  382. getList()
  383. getDeptList()
  384. })
  385. </script>
  386. <style lang="less" scoped>
  387. .app-container {
  388. padding: 20px;
  389. }
  390. </style>