index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <!-- 搜索 -->
  3. <ContentWrap>
  4. <!-- 搜索工作栏 -->
  5. <el-form
  6. class="-mb-15px"
  7. :model="queryParams"
  8. ref="queryFormRef"
  9. :inline="true"
  10. label-width="80px"
  11. >
  12. <el-form-item label="餐厅名称" prop="restaurantName">
  13. <TgInput @keyup.enter="handleQuery" v-model="queryParams.restaurantName" class="!w-240px" placeholder="请输入餐厅名称"/>
  14. </el-form-item>
  15. <el-form-item label="点餐月份" prop="month">
  16. <TgDatePicker type="month" v-model="queryParams.month" class="!w-240px" />
  17. </el-form-item>
  18. <el-form-item label="楼栋">
  19. <el-select
  20. v-model="queryParams.buildId"
  21. placeholder="选择楼栋"
  22. style="width: 180px"
  23. @change="handleBuildChange"
  24. >
  25. <el-option
  26. v-for="(item, index) in buildList"
  27. :key="index"
  28. :label="item.buildName"
  29. :value="item.id"
  30. />
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="楼层">
  34. <el-select v-model="queryParams.floorId" placeholder="选择楼层" style="width: 180px">
  35. <el-option
  36. v-for="(item, index) in floorList"
  37. :key="index"
  38. :label="item.floorName"
  39. :value="item.id"
  40. />
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item label="长者姓名" prop="elderId">
  44. <SelectElder v-model="queryParams.elderId" class="!w-240px" />
  45. </el-form-item>
  46. <el-form-item>
  47. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  48. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  49. </el-form-item>
  50. </el-form>
  51. </ContentWrap>
  52. <!-- 列表 -->
  53. <ContentWrap>
  54. <TabBarBtn @add="openForm()" @export="handleExport" @import="handleInput" />
  55. <Table2
  56. v-loading="loading"
  57. :data="list"
  58. :columns="DishedStatisticColumns"
  59. :queryParams="queryParams"
  60. :opWidth="240"
  61. @edit="(arg) => openForm(arg)"
  62. @detail="(arg) => openForm(arg, true)"
  63. @del="handleDelete"
  64. >
  65. <template #pre="{scope}">
  66. <el-button v-if="scope.status == 0" link type="info" @click="handleCancel(scope)">取消</el-button>
  67. </template>
  68. <template #next="{scope}">
  69. <el-button @click="handleExportItem(scope)" link type="warning">导出</el-button>
  70. </template>
  71. </Table2>
  72. <!-- 分页 -->
  73. <Pagination
  74. :total="total"
  75. v-model:page="queryParams.pageNo"
  76. v-model:limit="queryParams.pageSize"
  77. @pagination="getList"
  78. />
  79. </ContentWrap>
  80. <Form ref="formRef" @success="getList" />
  81. <Import
  82. ref="importRef"
  83. @success="getList"
  84. :config="{
  85. title: '导入',
  86. downloadUrl: 'restaurant/dishesOrderStatistics/downloadExcel',
  87. excelTempName: '机构养老-【导入点餐统计】模板',
  88. importUrl: '/restaurant/dishesOrderStatistics/importDishesOrderStatisticsExcel',
  89. failExportUrl: ''
  90. }"
  91. />
  92. </template>
  93. <script lang="ts" setup>
  94. import { getDishesOrderStatisticsPage, delDishesOrderStatistics, cancelDishesOrderStatistics, exportDishesOrderStatisticsExcel, exportDishesOrderItemExcel } from "@/api/system/foods";
  95. import { DishedStatisticColumns } from '../column'
  96. import Form from './Form.vue'
  97. import download from '@/utils/download'
  98. import Import from "@/components/ImportFile/index.vue";
  99. import {ref} from "vue";
  100. import { getBuildList } from '@/api/system/badManage'
  101. import { useUserStore } from '@/store/modules/user'
  102. const userStore = useUserStore()
  103. defineOptions({ name: 'OrderStatistics' })
  104. const message = useMessage() // 消息弹窗
  105. const { t } = useI18n() // 国际化
  106. const loading = ref(true) // 列表的加载中
  107. const total = ref(0) // 列表的总页数
  108. const list = ref([]) // 列表的数据
  109. const queryParams = reactive({
  110. pageNo: 1,
  111. pageSize: 10,
  112. restaurantName: undefined,
  113. month: undefined,
  114. elderId: undefined,
  115. buildId: '',
  116. floorId: '',
  117. })
  118. const queryFormRef = ref() // 搜索的表单
  119. const floorList = ref([])
  120. const buildList = ref([])
  121. /** 查询列表 */
  122. const getList = async () => {
  123. loading.value = true
  124. try {
  125. const data = await getDishesOrderStatisticsPage(queryParams)
  126. list.value = data.list
  127. total.value = data.total
  128. } finally {
  129. loading.value = false
  130. }
  131. }
  132. /** 搜索按钮操作 */
  133. const handleQuery = () => {
  134. queryParams.pageNo = 1
  135. getList()
  136. }
  137. /** 重置按钮操作 */
  138. const resetQuery = () => {
  139. queryFormRef.value.resetFields()
  140. handleQuery()
  141. }
  142. /** 添加/修改操作 */
  143. const formRef = ref()
  144. const openForm = (row: any = {}, detail: boolean = false) => {
  145. formRef.value.open(row.id, detail)
  146. }
  147. const handleBuildChange = (buildId: any) => {
  148. const selectedBuild = buildList.value.find((item: any) => item.id === buildId)
  149. if (selectedBuild) {
  150. floorList.value = selectedBuild.floorList || []
  151. }
  152. }
  153. const handleExport = async () => {
  154. const data = await exportDishesOrderStatisticsExcel(queryParams)
  155. download.excel(data, `点餐统计${Date.now()}.xls`)
  156. }
  157. const importRef = ref() //导入
  158. //导入
  159. const handleInput = () => {
  160. importRef.value.open()
  161. }
  162. const handleExportItem = async (item) => {
  163. const data = await exportDishesOrderItemExcel(item.id)
  164. download.excel(data, `点餐统计详情${Date.now()}.xls`)
  165. }
  166. const handleCancel = async (row) => {
  167. try{
  168. // 删除的二次确认
  169. await message.delConfirm('确定要取消吗?')
  170. await cancelDishesOrderStatistics(row.id)
  171. message.success(t('common.updateSuccess'))
  172. // 刷新列表
  173. await getList()
  174. }catch{}
  175. }
  176. /** 删除按钮操作 */
  177. const handleDelete = async (id) => {
  178. try {
  179. // 删除的二次确认
  180. await message.delConfirm()
  181. // 发起删除
  182. await delDishesOrderStatistics([id])
  183. message.success(t('common.delSuccess'))
  184. // 刷新列表
  185. await getList()
  186. } catch {}
  187. }
  188. /** 初始化 **/
  189. onMounted(async() => {
  190. getList()
  191. try {
  192. buildList.value = await getBuildList({ tenantIds: userStore.orgTenantId[0] })
  193. } catch (e) {}
  194. })
  195. </script>