index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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="请选择大队" 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="date">
  10. <el-date-picker clearable v-model="queryParams.date" type="date" placeholder="选择日期" value-format="YYYY-MM-DD"
  11. style="width: 200px" />
  12. </el-form-item>
  13. <el-form-item label="班次" prop="shift">
  14. <el-select v-model="queryParams.shift" placeholder="请选择班次" clearable style="width: 200px">
  15. <el-option label="白班" value="白班" />
  16. <el-option label="夜班" value="夜班" />
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item>
  20. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  21. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  22. </el-form-item>
  23. </el-form>
  24. <el-row :gutter="10" class="mb8">
  25. <el-col :span="1.5">
  26. <el-button type="primary" plain icon="Plus" @click="handleAdd"
  27. v-hasPermi="['rateList:rateList:add']">新增</el-button>
  28. </el-col>
  29. <el-col :span="1.5">
  30. <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
  31. v-hasPermi="['rateList:rateList:remove']">删除</el-button>
  32. </el-col>
  33. <el-col :span="1.5">
  34. <el-button type="warning" plain icon="Download" @click="handleExport"
  35. v-hasPermi="['rateList:rateList:export']">导出</el-button>
  36. </el-col>
  37. <el-col :span="1.5">
  38. <el-button type="info" plain icon="Upload" @click="handleImport"
  39. v-hasPermi="['rateList:rateList:import']">导入</el-button>
  40. </el-col>
  41. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  42. </el-row>
  43. <el-table v-loading="loading" :data="rateList" @selection-change="handleSelectionChange">
  44. <el-table-column type="selection" width="55" align="center" />
  45. <el-table-column label="日期" align="center" prop="date" width="120" />
  46. <el-table-column label="旅检国内区域平均速率(高峰期时段)" align="center" prop="domesticAvgRate" width="220" />
  47. <el-table-column label="当班大队" align="center" prop="dutyBrigade" width="120" />
  48. <el-table-column label="T1-A速率(高峰期时段)" align="center" prop="t1ARate" width="180" />
  49. <el-table-column label="T1-B速率(高峰期时段)" align="center" prop="t1BRate" width="180" />
  50. <el-table-column label="T2国内速率(高峰期时段)" align="center" prop="t2DomesticRate" width="180" />
  51. <el-table-column label="T2国际速率(高峰期时段)" align="center" prop="t2InternationalRate" width="180" />
  52. <el-table-column label="班次" align="center" prop="shift" width="100" />
  53. <el-table-column label="T2中转(高峰期时段)" align="center" prop="t2TransferRate" width="160" />
  54. <el-table-column label="国际及中转区域平均速率(高峰期时段)" align="center" prop="internationalTransferAvgRate" width="240" />
  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="['rateList:rateList:edit']">修改</el-button>
  59. <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
  60. v-hasPermi="['rateList:rateList: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="800px" append-to-body>
  67. <el-form ref="rateListRef" :model="form" :rules="rules" label-width="240px">
  68. <el-row :gutter="20">
  69. <el-col :span="12">
  70. <el-form-item label="日期" prop="date">
  71. <el-date-picker v-model="form.date" 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="dutyBrigade">
  77. <el-select v-model="form.dutyBrigade" placeholder="请选择当班大队" 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="shift">
  86. <el-select v-model="form.shift" placeholder="请选择班次" style="width: 100%">
  87. <el-option label="白班" value="白班" />
  88. <el-option label="夜班" value="夜班" />
  89. </el-select>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="12">
  93. <el-form-item label="旅检国内区域平均速率(高峰期时段)" prop="domesticAvgRate">
  94. <el-input-number v-model="form.domesticAvgRate" :min="0" :precision="2" 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-A速率(高峰期时段)" prop="t1ARate">
  101. <el-input-number v-model="form.t1ARate" :min="0" :precision="2" style="width: 100%" />
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="12">
  105. <el-form-item label="T1-B速率(高峰期时段)" prop="t1BRate">
  106. <el-input-number v-model="form.t1BRate" :min="0" :precision="2" 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="t2DomesticRate">
  113. <el-input-number v-model="form.t2DomesticRate" :min="0" :precision="2" style="width: 100%" />
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="12">
  117. <el-form-item label="T2国际速率(高峰期时段)" prop="t2InternationalRate">
  118. <el-input-number v-model="form.t2InternationalRate" :min="0" :precision="2" 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="T2中转(高峰期时段)" prop="t2TransferRate">
  125. <el-input-number v-model="form.t2TransferRate" :min="0" :precision="2" style="width: 100%" />
  126. </el-form-item>
  127. </el-col>
  128. <el-col :span="12">
  129. <el-form-item label="国际及中转区域平均速率(高峰期时段)" prop="internationalTransferAvgRate">
  130. <el-input-number v-model="form.internationalTransferAvgRate" :min="0" :precision="2" style="width: 100%" />
  131. </el-form-item>
  132. </el-col>
  133. </el-row>
  134. </el-form>
  135. <template #footer>
  136. <div class="dialog-footer">
  137. <el-button type="primary" @click="submitForm">确 定</el-button>
  138. <el-button @click="cancel">取 消</el-button>
  139. </div>
  140. </template>
  141. </el-dialog>
  142. <el-dialog title="导入" v-model="importOpen" width="500px" append-to-body>
  143. <el-upload ref="uploadRef" :auto-upload="false" :on-change="handleFileChange" :show-file-list="false"
  144. accept=".xlsx,.xls">
  145. <el-button type="primary">选取文件</el-button>
  146. <div class="el-upload__tip">只能上传xls/xlsx文件</div>
  147. </el-upload>
  148. <template #footer>
  149. <div class="dialog-footer">
  150. <el-button type="primary" @click="submitImport">确 定</el-button>
  151. <el-button @click="importOpen = false">取 消</el-button>
  152. </div>
  153. </template>
  154. </el-dialog>
  155. </div>
  156. </template>
  157. <script setup>
  158. import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
  159. import { listRate, getRate, delRate, addRate, updateRate, exportRate } from '@/api/blockingData/rateList'
  160. import { listDept } from '@/api/system/dept'
  161. const { proxy } = getCurrentInstance()
  162. const loading = ref(true)
  163. const ids = ref([])
  164. const single = ref(true)
  165. const multiple = ref(true)
  166. const showSearch = ref(true)
  167. const total = ref(0)
  168. const rateList = ref([])
  169. const title = ref('')
  170. const open = ref(false)
  171. const importOpen = ref(false)
  172. const importFile = ref(null)
  173. const queryParams = reactive({
  174. pageNum: 1,
  175. pageSize: 10,
  176. brigadeId: null,
  177. date: null,
  178. shift: null
  179. })
  180. const form = reactive({})
  181. const rules = {
  182. date: [{ required: true, message: '日期不能为空', trigger: 'change' }],
  183. dutyBrigade: [{ required: true, message: '当班大队不能为空', trigger: 'change' }],
  184. shift: [{ required: true, message: '班次不能为空', trigger: 'change' }]
  185. }
  186. const brigadeOptions = ref([])
  187. function getList() {
  188. loading.value = true
  189. listRate(queryParams).then(response => {
  190. rateList.value = response.rows
  191. total.value = response.total
  192. loading.value = false
  193. })
  194. }
  195. function getDeptList() {
  196. listDept({}).then(response => {
  197. const deptList = response.data || []
  198. brigadeOptions.value = deptList.filter(item => item.deptType === 'BRIGADE').map(item => ({
  199. value: item.deptId,
  200. label: item.deptName
  201. }))
  202. })
  203. }
  204. function cancel() {
  205. open.value = false
  206. reset()
  207. }
  208. function reset() {
  209. form.value = {
  210. id: null,
  211. date: null,
  212. dutyBrigade: null,
  213. shift: null,
  214. domesticAvgRate: 0,
  215. t1ARate: 0,
  216. t1BRate: 0,
  217. t2DomesticRate: 0,
  218. t2InternationalRate: 0,
  219. t2TransferRate: 0,
  220. internationalTransferAvgRate: 0
  221. }
  222. proxy.resetForm('rateListRef')
  223. }
  224. function handleQuery() {
  225. queryParams.pageNum = 1
  226. getList()
  227. }
  228. function resetQuery() {
  229. proxy.resetForm('queryRef')
  230. handleQuery()
  231. }
  232. function handleSelectionChange(selection) {
  233. ids.value = selection.map(item => item.id)
  234. single.value = selection.length !== 1
  235. multiple.value = !selection.length
  236. }
  237. function handleAdd() {
  238. reset()
  239. open.value = true
  240. title.value = '添加速率统计'
  241. }
  242. function handleUpdate(row) {
  243. reset()
  244. const id = row.id || ids.value[0]
  245. getRate(id).then(response => {
  246. Object.assign(form, response.data)
  247. open.value = true
  248. title.value = '修改速率统计'
  249. })
  250. }
  251. function submitForm() {
  252. proxy.$refs.rateListRef.validate(valid => {
  253. if (valid) {
  254. if (form.id != null) {
  255. updateRate(form).then(response => {
  256. proxy.$modal.msgSuccess('修改成功')
  257. open.value = false
  258. getList()
  259. })
  260. } else {
  261. addRate(form).then(response => {
  262. proxy.$modal.msgSuccess('新增成功')
  263. open.value = false
  264. getList()
  265. })
  266. }
  267. }
  268. })
  269. }
  270. function handleDelete(row) {
  271. const id = row.id || ids.value
  272. proxy.$modal.confirm('是否确认删除速率统计编号为"' + id + '"的数据项?').then(function () {
  273. return delRate(id)
  274. }).then(() => {
  275. getList()
  276. proxy.$modal.msgSuccess('删除成功')
  277. }).catch(() => { })
  278. }
  279. function handleExport() {
  280. proxy.download('rateList/export', {
  281. ...queryParams
  282. }, `速率统计_${new Date().getTime()}.xlsx`)
  283. }
  284. function handleImport() {
  285. importOpen.value = true
  286. importFile.value = null
  287. }
  288. function handleFileChange(file) {
  289. importFile.value = file.raw
  290. }
  291. function submitImport() {
  292. if (!importFile.value) {
  293. proxy.$modal.msgWarning('请选择要导入的文件')
  294. return
  295. }
  296. const formData = new FormData()
  297. formData.append('file', importFile.value)
  298. proxy.upload('rateList/importData', formData).then(response => {
  299. proxy.$modal.msgSuccess(response.msg)
  300. importOpen.value = false
  301. getList()
  302. })
  303. }
  304. onMounted(() => {
  305. getList()
  306. getDeptList()
  307. })
  308. </script>
  309. <style lang="less" scoped>
  310. .app-container {
  311. padding: 20px;
  312. }
  313. :deep(.el-table) {
  314. .el-table__header-wrapper {
  315. th {
  316. background-color: #303133;
  317. color: #ffffff;
  318. font-weight: 600;
  319. }
  320. }
  321. }
  322. </style>