index.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  1. <template>
  2. <div class="p-2">
  3. <transition :enter-active-class="proxy?.animate.searchAnimate.enter"
  4. :leave-active-class="proxy?.animate.searchAnimate.leave">
  5. <div v-show="showSearch" class="mb-[10px]">
  6. <div class="statistic-card">
  7. <el-row :gutter="20" justify="space-between">
  8. <!-- 总发布数 -->
  9. <el-col :span="6">
  10. <el-statistic :value="totalNum" class="statistic-item">
  11. <template #title>
  12. <div class="statistic-title">
  13. <el-icon><Collection /></el-icon>
  14. <span>总发布数</span>
  15. </div>
  16. </template>
  17. <template #prefix>
  18. <div class="statistic-icon total-icon">
  19. <el-icon><Promotion /></el-icon>
  20. </div>
  21. </template>
  22. </el-statistic>
  23. </el-col>
  24. <!-- 轮播组发布 -->
  25. <el-col :span="6">
  26. <el-statistic :value="lbNum" class="statistic-item">
  27. <template #title>
  28. <div class="statistic-title">
  29. <el-icon><RefreshRight /></el-icon>
  30. <span>轮播组发布</span>
  31. </div>
  32. </template>
  33. <template #prefix>
  34. <div class="statistic-icon carousel-icon">
  35. <el-icon><Refresh /></el-icon>
  36. </div>
  37. </template>
  38. </el-statistic>
  39. </el-col>
  40. <!-- 分屏组发布 -->
  41. <el-col :span="6">
  42. <el-statistic :value="jmNum" class="statistic-item">
  43. <template #title>
  44. <div class="statistic-title">
  45. <el-icon><Grid /></el-icon>
  46. <span>分屏组发布</span>
  47. </div>
  48. </template>
  49. <template #prefix>
  50. <div class="statistic-icon split-icon">
  51. <el-icon><Menu /></el-icon>
  52. </div>
  53. </template>
  54. </el-statistic>
  55. </el-col>
  56. <!-- 素材发布 -->
  57. <el-col :span="6">
  58. <el-statistic :value="scNum" class="statistic-item">
  59. <template #title>
  60. <div class="statistic-title">
  61. <el-icon><Files /></el-icon>
  62. <span>素材发布</span>
  63. </div>
  64. </template>
  65. <template #prefix>
  66. <div class="statistic-icon material-icon">
  67. <el-icon><Document /></el-icon>
  68. </div>
  69. </template>
  70. </el-statistic>
  71. </el-col>
  72. </el-row>
  73. </div>
  74. <el-card shadow="hover" :style="{ marginTop: '10px', height: '60px' }">
  75. <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="40px">
  76. <el-form-item label="名称" prop="name">
  77. <el-input v-model="queryParams.name" style="width: 150px" placeholder="请输入名称" clearable
  78. @keyup.enter="handleQuery" />
  79. </el-form-item>
  80. <el-form-item label="类型" prop="itemType">
  81. <el-select v-model="queryParams.itemType" style="width: 150px" placeholder="请选择类型" clearable>
  82. <el-option v-for="dict in smsb_push_type" :key="dict.value" :label="dict.label" :value="dict.value" />
  83. </el-select>
  84. </el-form-item>
  85. <el-form-item label="时间" style="width: 270px">
  86. <el-date-picker v-model="dateRangeCreateTime" value-format="YYYY-MM-DD HH:mm:ss" type="daterange"
  87. range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
  88. :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]" />
  89. </el-form-item>
  90. <el-form-item>
  91. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  92. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  93. <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['source:itemPush:add']">新增
  94. </el-button>
  95. <!-- <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()"
  96. v-hasPermi="['source:itemPush:edit']">修改
  97. </el-button>
  98. <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()"
  99. v-hasPermi="['source:itemPush:remove']">删除
  100. </el-button>-->
  101. <!-- <el-button type="warning" plain icon="Download" @click="handleExport"
  102. v-hasPermi="['source:itemPush:export']">导出
  103. </el-button>-->
  104. </el-form-item>
  105. </el-form>
  106. </el-card>
  107. </div>
  108. </transition>
  109. <el-card shadow="never">
  110. <div class="table-content">
  111. <el-table v-loading="loading" :data="itemPushList" @selection-change="handleSelectionChange">
  112. <!-- <el-table-column type="selection" width="55" align="center" />-->
  113. <el-table-column label="" align="left" prop="" width="10" />
  114. <el-table-column label="ID" align="left" prop="id" width="180" v-if="true" />
  115. <el-table-column label="名称" align="left" prop="name" width="500"/>
  116. <el-table-column label="优先级" align="center" width="100" prop="level">
  117. <template #default="scope">
  118. <dict-tag :options="smsb_push_level" :value="scope.row.level" />
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="类型" align="center" width="100" prop="itemType">
  122. <template #default="scope">
  123. <dict-tag :options="smsb_push_type" :value="scope.row.itemType" />
  124. </template>
  125. </el-table-column>
  126. <el-table-column label="审核状态" align="center" width="100" prop="status">
  127. <template #default="scope">
  128. <dict-tag :options="smsb_push_state" :value="scope.row.status" />
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="上架状态" align="center" width="100" prop="isUse">
  132. <template #default="scope">
  133. <dict-tag :options="smsb_push_isuse" :value="scope.row.isUse" />
  134. </template>
  135. </el-table-column>
  136. <el-table-column label="生效日期" align="left" prop="startDate" width="100">
  137. <template #default="scope">
  138. <span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }}</span>
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="失效日期" align="left" prop="endDate" width="100">
  142. <template #default="scope">
  143. <span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="创建人" align="left" prop="createUser" width="100" :show-overflow-tooltip="true" />
  147. <el-table-column label="发布时间" align="left" prop="createTime" :show-overflow-tooltip="true" />
  148. <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" width="150">
  149. <template #default="scope">
  150. <!-- <el-tooltip content="修改" placement="top">
  151. <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
  152. v-hasPermi="['source:itemPush:edit']"></el-button>
  153. </el-tooltip> -->
  154. <!-- <el-tooltip content="提交审核" placement="top">
  155. <el-button link type="primary" icon="Top" @click="handleReview(scope.row)"
  156. v-hasPermi="['source:minioData:add']"></el-button>
  157. </el-tooltip>-->
  158. <el-tooltip content="下发详情" placement="top">
  159. <el-button link type="primary" icon="List" @click="handleDevice(scope.row)"
  160. v-hasPermi="['source:itemPush:edit']">详情</el-button>
  161. </el-tooltip>
  162. <el-tooltip content="下架" placement="top">
  163. <el-button link type="primary" icon="Bottom" v-if="scope.row.status == 'finish' && scope.row.isUse == '1'"
  164. @click="handleRemoveItem(scope.row)" v-hasPermi="['source:itemPush:edit']">下架</el-button>
  165. </el-tooltip>
  166. <el-tooltip content="删除" placement="top">
  167. <el-button link type="primary" icon="Delete" v-if="scope.row.isUse == '0'" @click="handleDelete(scope.row)"
  168. v-hasPermi="['source:itemPush:remove']">删除</el-button>
  169. </el-tooltip>
  170. </template>
  171. </el-table-column>
  172. </el-table>
  173. </div>
  174. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
  175. v-model:limit="queryParams.pageSize" @pagination="getList" />
  176. </el-card>
  177. <!-- 添加或修改内容发布对话框 -->
  178. <el-dialog :title="dialog.title" v-model="dialog.visible" width="1500px" style="height: 750px" append-to-body>
  179. <el-row :gutter="20" style="height: 100%; display: flex">
  180. <!--设备列表-->
  181. <el-col :span="6" style="height: 100%; overflow: auto; padding-right: 10px">
  182. <el-row style="margin-bottom: 13px;margin-top: 5px">
  183. <el-input v-model="queryParams.deviceName" placeholder="请输入设备名称" clearable style="width: 270px" />
  184. <el-button type="primary" @click="getDeviceList" style="margin-left: 10px">查询</el-button>
  185. </el-row>
  186. <el-table v-loading="loading" border fit highlight-current-row :data="deviceList" @selection-change="handleSelectDevice" style="height: 520px">
  187. <el-table-column type="selection" width="55" align="center" />
  188. <el-table-column label="设备名称" align="left" prop="name" :show-overflow-tooltip="true" />
  189. </el-table>
  190. </el-col>
  191. <!--发布名称-->
  192. <el-col :span="9" style="height: 570px; overflow: auto; padding-left: 10px">
  193. <el-form ref="itemPushFormRef" :model="form" :rules="rules" style="margin-top: 5px" label-width="60px">
  194. <el-form-item label="名称" prop="name">
  195. <el-input v-model="form.name" placeholder="请输入名称" />
  196. </el-form-item>
  197. <el-row>
  198. <el-col :span="12">
  199. <el-form-item label="类型" prop="itemType">
  200. <el-select v-model="form.itemType" placeholder="请选择类型" @change="getItemList">
  201. <el-option v-for="dict in smsb_push_type" :key="dict.value" :label="dict.label"
  202. :value="parseInt(dict.value)"></el-option>
  203. </el-select>
  204. </el-form-item>
  205. </el-col>
  206. <el-col :span="12">
  207. <el-form-item label="优先级" prop="level">
  208. <el-select v-model="form.level" @change="pushLevelChange" placeholder="请选择优先级">
  209. <el-option v-for="dict in smsb_push_level" :key="dict.value" :label="dict.label"
  210. :value="parseInt(dict.value)" ></el-option>
  211. </el-select>
  212. </el-form-item>
  213. </el-col>
  214. </el-row>
  215. <el-form-item label="日期" prop="dateRange">
  216. <el-date-picker v-model="form.dateRange" value-format="YYYY-MM-DD" type="daterange" range-separator="-"
  217. start-placeholder="开始日期" end-placeholder="结束日期"
  218. :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]" />
  219. </el-form-item>
  220. <!-- Days of the Week -->
  221. <!-- <el-form-item label="每周">
  222. <el-checkbox-group v-model="form.weekDays">
  223. <el-checkbox label="0">日</el-checkbox>
  224. <el-checkbox label="1">一</el-checkbox>
  225. <el-checkbox label="2">二</el-checkbox>
  226. <el-checkbox label="3">三</el-checkbox>
  227. <el-checkbox label="4">四</el-checkbox>
  228. <el-checkbox label="5">五</el-checkbox>
  229. <el-checkbox label="6">六</el-checkbox>
  230. </el-checkbox-group>
  231. </el-form-item>-->
  232. <!-- Time Periods -->
  233. <el-form-item label="时间">
  234. <div v-for="(timePeriod, index) in form.timeRange" :key="index" class="time-period">
  235. <el-time-picker v-model="timePeriod.start" placeholder="开始时间" format="HH:mm:ss" style="width: 150px;" :disabled="false" />
  236. <span>至</span>
  237. <el-time-picker v-model="timePeriod.end" placeholder="结束时间" format="HH:mm:ss" style="width: 150px;" :disabled="false" />
  238. <el-button @click="removeTimePeriod(index)" type="danger" style="margin-left: 10px" icon="Delete"></el-button>
  239. </div>
  240. <el-button @click="addTimePeriod" type="primary">新增时间段</el-button>
  241. </el-form-item>
  242. </el-form>
  243. </el-col>
  244. <!--发布内容-->
  245. <el-col :span="9" style="height: 100%; overflow: auto; padding-left: 10px">
  246. <!--轮播组 -->
  247. <div v-if="form.itemType === 1 || form.itemType === 3">
  248. <el-table v-loading="loading" border fit highlight-current-row :data="itemList" style="height: 570px">
  249. <el-table-column label="ID" width="200" align="left" :show-overflow-tooltip="true">
  250. <template #default="{ row }">
  251. <el-radio v-model="selectedRowId" :label="row.id" @change="handleRadioChange(row)" />
  252. </template>
  253. </el-table-column>
  254. <el-table-column label="名称" align="left" prop="itemName" :show-overflow-tooltip="true" />
  255. <!-- <el-table-column label="资源数量" align="center" prop="sourceNum" width="80" />-->
  256. <el-table-column label="创建人" align="center" prop="createUser" width="120" :show-overflow-tooltip="true" />
  257. </el-table>
  258. </div>
  259. <!-- 素材 -->
  260. <div v-if="form.itemType === 4 ">
  261. <el-table v-loading="loading" border fit highlight-current-row :data="minioDataList" style="height: 570px" @selection-change="handleSelectionMinioChange">
  262. <el-table-column type="selection" width="40" align="center" />
  263. <el-table-column label="ID" prop="id" width="170" align="left" :show-overflow-tooltip="true" />
  264. <el-table-column label="文件" align="left" prop="originalName" :show-overflow-tooltip="true" />
  265. <el-table-column label="预览" align="center" prop="screenshot" width="80">
  266. <template #default="scope">
  267. <div v-if="scope.row.type === 1">
  268. <!-- 图片类型 -->
  269. <image-preview :src="scope.row.screenshot" style="width: 40px; height: 40px; cursor: pointer" />
  270. </div>
  271. <div v-else-if="scope.row.type === 2">
  272. <el-icon class="VideoPlay" @click="viewVideo(scope.row.screenshot)" size="40" style="cursor: pointer">
  273. <VideoPlay />
  274. </el-icon>
  275. </div>
  276. <div v-else-if="scope.row.type === 4">
  277. <!-- PPT类型 -->
  278. <el-icon :size="40" @click="downloadFile(scope.row.fileUrl)" style="cursor: pointer;">
  279. <Document />
  280. </el-icon>
  281. </div>
  282. </template>
  283. </el-table-column>
  284. </el-table>
  285. </div>
  286. </el-col>
  287. </el-row>
  288. <template #footer>
  289. <div class="dialog-footer">
  290. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
  291. <el-button @click="cancel">取 消</el-button>
  292. </div>
  293. </template>
  294. </el-dialog>
  295. <!-- 下发详情弹窗 -->
  296. <el-dialog :title="deviceDialog.title" v-model="deviceDialog.visible" width="1400px" append-to-body>
  297. <!--发布名称-->
  298. <div>
  299. <el-descriptions title="详情信息" :column="2" border>
  300. <el-descriptions-item label="发布名称">
  301. {{form.name}}
  302. </el-descriptions-item>
  303. <el-descriptions-item label="发布类型">
  304. <dict-tag :options="smsb_push_type" :value="form.itemType" />
  305. </el-descriptions-item>
  306. <el-descriptions-item label="开始时间">
  307. {{form.startDate}}
  308. </el-descriptions-item>
  309. <el-descriptions-item label="结束时间">
  310. {{form.endDate}}
  311. </el-descriptions-item>
  312. </el-descriptions>
  313. </div>
  314. <el-row :gutter="20">
  315. <el-col :span="12">
  316. <el-table v-loading="deviceLoading" border fit highlight-current-row :data="pushSourceList" style="height: 542px; margin-top: 10px">
  317. <el-table-column label="排序" align="center" prop="sort" width="60" :show-overflow-tooltip="true" />
  318. <el-table-column label="时长" align="center" prop="duration" width="80" :show-overflow-tooltip="true"/>
  319. <el-table-column label="资源" align="left" prop="fileName" :show-overflow-tooltip="true"/>
  320. <el-table-column label="预览" align="center" prop="screenshot" width="120">
  321. <template #default="scope">
  322. <div v-if="scope.row.fileType === 1">
  323. <image-preview :src="scope.row.screenshot" style="width: 40px; height: 40px; cursor: pointer" />
  324. </div>
  325. <div v-else-if="scope.row.fileType === 2">
  326. <el-icon class="VideoPlay" @click="viewVideo(scope.row.screenshot)" size="40" style="cursor: pointer">
  327. <VideoPlay />
  328. </el-icon>
  329. </div>
  330. <div v-else-if="scope.row.fileType === 4">
  331. <!-- PPT类型 -->
  332. <el-icon :size="40" @click="downloadFile(scope.row.fileUrl)" style="cursor: pointer;">
  333. <Document />
  334. </el-icon>
  335. </div>
  336. </template>
  337. </el-table-column>
  338. </el-table>
  339. </el-col>
  340. <el-col :span="12">
  341. <!--设备列表-->
  342. <el-button type="primary" v-if="removeItemTag" icon="Bottom" :disabled="removeButtonTag"
  343. @click="handleDoRemoveItem()" style="margin-top: 10px"> 下架 </el-button>
  344. <el-table v-loading="deviceLoading" border fit highlight-current-row :data="pushDeviceList" style="height: 500px; margin-top: 10px"
  345. @selection-change="handleDeviceSelectionChange">
  346. <el-table-column type="selection" v-if="removeItemTag" width="55" align="center" />
  347. <el-table-column label="设备名称" align="left" prop="deviceName" :show-overflow-tooltip="true" />
  348. <el-table-column label="发布排序" align="center" prop="sortNum" width="80" :show-overflow-tooltip="true" />
  349. <el-table-column label="发布状态" align="center" prop="pushState" width="100" :show-overflow-tooltip="true">
  350. <template #default="scope">
  351. <dict-tag :options="smsb_push_device_state" :value="scope.row.pushState" />
  352. </template>
  353. </el-table-column>
  354. <el-table-column label="发布时间" align="left" prop="createTime" width="160" :show-overflow-tooltip="true" />
  355. <el-table-column label="操作" v-if="removeItemTag" align="center" class-name="small-padding fixed-width"
  356. width="80">
  357. <template #default="scope">
  358. <el-tooltip content="下架" placement="top">
  359. <el-button link type="primary" icon="Bottom" @click="handleDoRemoveItem(scope.row)"
  360. v-hasPermi="['source:itemPush:edit']">下架</el-button>
  361. </el-tooltip>
  362. </template>
  363. </el-table-column>
  364. </el-table>
  365. </el-col>
  366. </el-row>
  367. <template #footer>
  368. <div class="dialog-footer">
  369. <el-button @click="cancel">取 消</el-button>
  370. </div>
  371. </template>
  372. </el-dialog>
  373. <!-- 用于展示播放的视频 -->
  374. <el-dialog v-model="videoDialogVisible" append-to-body>
  375. <video width="100%" controls :src="videoUrl"></video>
  376. </el-dialog>
  377. </div>
  378. </template>
  379. <script setup name="ItemPush" lang="ts">
  380. import {
  381. addItemPush,
  382. delItemPush,
  383. getItemPush,
  384. listItemPush,
  385. pushStatistics,
  386. reviewItemPush,
  387. updateItemPush,
  388. validateTime,
  389. } from '@/api/smsb/source/item_push';
  390. import {ItemPushForm, ItemPushQuery, ItemPushVO} from '@/api/smsb/source/item_push_type';
  391. import {DeviceQuery, DeviceVO} from '@/api/smsb/device/device_type';
  392. import {listDevice} from '@/api/smsb/device/device';
  393. import {ItemQuery, ItemVO} from '@/api/smsb/source/item_type';
  394. import {listItem, listItemPushSource} from '@/api/smsb/source/item';
  395. import {ItemPushDeviceVO} from '@/api/smsb/source/item_push_device_type';
  396. import {listItemPushDeviceV2, removeItemPushDevice} from '@/api/smsb/source/item_push_device';
  397. import {MinioDataVO} from "@/api/smsb/source/minioData_type";
  398. import {listMinioData} from "@/api/smsb/source/minioData";
  399. import {ItemFileRelVO} from "@/api/smsb/source/itemFile_type";
  400. const {proxy} = getCurrentInstance() as ComponentInternalInstance;
  401. const {smsb_push_state, smsb_push_device_state, smsb_push_type, smsb_push_level,smsb_push_isuse} = toRefs<any>(
  402. proxy?.useDict('smsb_push_state', 'smsb_push_device_state', 'smsb_push_type', 'smsb_push_level','smsb_push_isuse')
  403. );
  404. const itemPushList = ref<ItemPushVO[]>([]);
  405. const itemList = ref<ItemVO[]>([]);
  406. const minioDataList = ref<MinioDataVO[]>([]);
  407. const buttonLoading = ref(false);
  408. const loading = ref(true);
  409. const deviceLoading = ref(true);
  410. const showSearch = ref(true);
  411. const ids = ref<Array<string | number>>([]);
  412. const removePushId = ref<number | string>();
  413. const removeIds = ref<Array<string | number>>([]);
  414. const deviceIds = ref<Array<string | number>>([]);
  415. const itemIds = ref<Array<string | number>>([]);
  416. const single = ref(true);
  417. const multiple = ref(true);
  418. const total = ref(0);
  419. const deviceTotal = ref(0);
  420. const itemTotal = ref(0);
  421. const totalNum = ref(0);
  422. const lbNum = ref(0);
  423. const jmNum = ref(0);
  424. const scNum = ref(0);
  425. const dateRangeCreateTime = ref<[DateModelType, DateModelType]>(['', '']);
  426. const deviceList = ref<DeviceVO[]>([]);
  427. const pushDeviceList = ref<ItemPushDeviceVO[]>([]);
  428. const pushSourceList = ref<ItemFileRelVO[]>([]);
  429. // 存储选中行的唯一标识
  430. const selectedRowId = ref<number | null>(null);
  431. const selectedMinioDataIds = ref<Array<number | string>>([]);
  432. const removeItemTag = ref(false);
  433. const removeButtonTag = ref(true);
  434. const queryFormRef = ref<ElFormInstance>();
  435. const itemPushFormRef = ref<ElFormInstance>();
  436. const videoUrl = ref('');
  437. const videoDialogVisible = ref(false);
  438. const dialog = reactive<DialogOption>({
  439. visible: false,
  440. title: ''
  441. });
  442. const deviceDialog = reactive<DialogOption>({
  443. visible: false,
  444. title: ''
  445. });
  446. const initFormData: ItemPushForm = {
  447. name: undefined,
  448. level: 200,
  449. itemType: 1, // "分屏组"类型
  450. deviceIds: undefined,
  451. itemIds: undefined,
  452. dateRange: undefined,
  453. weekDays: ['0', '1', '2', '3', '4', '5', '6'],
  454. timeRange: []
  455. };
  456. const data = reactive<PageData<ItemPushForm, ItemPushQuery>>({
  457. form: { ...initFormData },
  458. queryParams: {
  459. pageNum: 1,
  460. pageSize: 20,
  461. name: undefined,
  462. level: undefined,
  463. itemType: undefined,
  464. status: undefined,
  465. params: {
  466. createTime: undefined
  467. }
  468. },
  469. rules: {}
  470. });
  471. const dialogData = reactive<DialogPageData<DeviceQuery>>({
  472. dialogQueryParams: {
  473. pageNum: 1,
  474. pageSize: 10000,
  475. pushId: undefined
  476. }
  477. });
  478. const itemData = reactive<TransPageData<ItemQuery>>({
  479. transQueryParams: {
  480. pageNum: 1,
  481. pageSize: 10000,
  482. itemType: undefined,
  483. types: undefined
  484. }
  485. });
  486. const { queryParams, form, rules } = toRefs(data);
  487. const { dialogQueryParams } = toRefs(dialogData);
  488. const { transQueryParams } = toRefs(itemData);
  489. const getStatistics = async () => {
  490. const res = await pushStatistics();
  491. console.log(res.data);
  492. totalNum.value = res.data.totalNum;
  493. lbNum.value = res.data.lbNum;
  494. jmNum.value = res.data.jmNum;
  495. scNum.value = res.data.scNum;
  496. };
  497. /** 查询内容发布列表 */
  498. const getList = async () => {
  499. loading.value = true;
  500. queryParams.value.params = {};
  501. proxy?.addDateRange(queryParams.value, dateRangeCreateTime.value, 'CreateTime');
  502. const res = await listItemPush(queryParams.value);
  503. itemPushList.value = res.rows;
  504. total.value = res.total;
  505. loading.value = false;
  506. };
  507. /** 查询设备列表 */
  508. const getDeviceList = async () => {
  509. dialogQueryParams.value.name = queryParams.value.deviceName;
  510. const res = await listDevice(dialogQueryParams.value);
  511. deviceList.value = res.rows;
  512. deviceTotal.value = res.total;
  513. loading.value = false;
  514. };
  515. const getItemList = async () => {
  516. transQueryParams.value.itemType = form.value.itemType;
  517. if (form.value.itemType === 1 || form.value.itemType === 3) {
  518. const res = await listItem(transQueryParams.value);
  519. itemList.value = res.rows;
  520. itemTotal.value = res.total;
  521. }
  522. if (form.value.itemType === 4) {
  523. if (form.value.level === 400) {
  524. transQueryParams.value.types = [1, 2, 3, 4];
  525. }else {
  526. transQueryParams.value.types = [1, 2, 3];
  527. }
  528. const res = await listMinioData(transQueryParams.value);
  529. minioDataList.value = res.rows;
  530. }
  531. };
  532. const pushLevelChange = async () => {
  533. if (form.value.itemType === 4) {
  534. if (form.value.level === 400) {
  535. transQueryParams.value.types = [1, 2, 3, 4];
  536. }else {
  537. transQueryParams.value.types = [1, 2, 3];
  538. }
  539. const res = await listMinioData(transQueryParams.value);
  540. minioDataList.value = res.rows;
  541. }
  542. }
  543. // 播放视频
  544. const viewVideo = (url: string) => {
  545. videoUrl.value = url;
  546. videoDialogVisible.value = true;
  547. };
  548. const downloadFile = (fileUrl) => {
  549. if (fileUrl) {
  550. // 创建一个隐藏的a标签来触发下载
  551. const link = document.createElement('a');
  552. link.href = fileUrl;
  553. link.download = ''; // 浏览器会自动使用URL中的文件名
  554. link.target = '_blank';
  555. link.style.display = 'none';
  556. document.body.appendChild(link);
  557. link.click();
  558. document.body.removeChild(link);
  559. } else {
  560. proxy?.$modal.msgError('文件地址不存在,无法下载');
  561. }
  562. };
  563. const addTimePeriod = () => {
  564. const now = new Date();
  565. now.setHours(0, 0, 0, 0);
  566. const end = new Date();
  567. end.setHours(23, 59, 59, 0);
  568. if (form.value.timeRange.length >= 5) {
  569. proxy?.$modal.msgError('时间段最多支持添加5个!');
  570. return;
  571. }
  572. form.value.timeRange.push({start: new Date(now), end: new Date(end)});
  573. };
  574. const removeTimePeriod = (index: number) => {
  575. form.value.timeRange.splice(index, 1);
  576. };
  577. /** 取消按钮 */
  578. const cancel = () => {
  579. reset();
  580. dialog.visible = false;
  581. deviceDialog.visible = false;
  582. videoDialogVisible.value = false;
  583. };
  584. /** 表单重置 */
  585. const reset = () => {
  586. form.value = { ...initFormData };
  587. itemPushFormRef.value?.resetFields();
  588. };
  589. /** 搜索按钮操作 */
  590. const handleQuery = () => {
  591. queryParams.value.pageNum = 1;
  592. getList();
  593. };
  594. const handleDevice = async (row?: ItemPushVO) => {
  595. removeItemTag.value = false;
  596. const pushId = row.id;
  597. deviceDialog.title = '下发详情';
  598. deviceDialog.visible = true;
  599. dialogQueryParams.value.pushId = pushId;
  600. // dialogQueryParams.value.pageSize = 1000;
  601. pushDeviceList.value = [];
  602. const pushInfo = await getItemPush(pushId);
  603. Object.assign(form.value, pushInfo.data);
  604. await getItemDeviceList(pushId);
  605. await getItemSourceList(pushId);
  606. };
  607. const handleRemoveItem = async (row?: ItemPushVO) => {
  608. removeItemTag.value = true;
  609. removeButtonTag.value = true;
  610. removeIds.value = [];
  611. const pushId = row.id;
  612. deviceDialog.title = '下架';
  613. deviceDialog.visible = true;
  614. dialogQueryParams.value.pushId = pushId;
  615. removePushId.value = pushId;
  616. dialogQueryParams.value.pageSize = 1000;
  617. pushDeviceList.value = [];
  618. const pushInfo = await getItemPush(pushId);
  619. Object.assign(form.value, pushInfo.data);
  620. await getItemDeviceList(pushId);
  621. await getItemSourceList(pushId);
  622. };
  623. const handleDoRemoveItem = async (row?: ItemPushDeviceVO) => {
  624. const deviceIds = Array<number | string>();
  625. if (null != row) {
  626. deviceIds.push(row.deviceId);
  627. }
  628. if (removeIds.value.length > 0) {
  629. removeIds.value.forEach((deviceId) => {
  630. deviceIds.push(deviceId);
  631. });
  632. }
  633. const removeParam = {
  634. pushId: removePushId.value,
  635. deviceIds: deviceIds
  636. };
  637. await removeItemPushDevice(removeParam);
  638. await getItemDeviceList(removePushId.value);
  639. };
  640. const getItemDeviceList = async (pushId: number | string) => {
  641. deviceLoading.value = true;
  642. dialogQueryParams.value.pushId = pushId;
  643. const res = await listItemPushDeviceV2(dialogQueryParams.value);
  644. pushDeviceList.value = res.data;
  645. deviceLoading.value = false;
  646. };
  647. const getItemSourceList = async (pushId: number | string) => {
  648. deviceLoading.value = true;
  649. const res = await listItemPushSource(pushId);
  650. pushSourceList.value = res.data;
  651. deviceLoading.value = false;
  652. };
  653. /** 重置按钮操作 */
  654. const resetQuery = () => {
  655. dateRangeCreateTime.value = ['', ''];
  656. queryFormRef.value?.resetFields();
  657. handleQuery();
  658. };
  659. /** 多选框选中数据 */
  660. const handleSelectionChange = (selection: ItemPushVO[]) => {
  661. ids.value = selection.map((item) => item.id);
  662. single.value = selection.length != 1;
  663. multiple.value = !selection.length;
  664. };
  665. const handleDeviceSelectionChange = (selection: ItemPushDeviceVO[]) => {
  666. removeIds.value = selection.map((item) => item.deviceId);
  667. removeButtonTag.value = removeIds.value.length == 0;
  668. };
  669. /** 多选框选中数据 */
  670. const handleSelectDevice = (selection: DeviceVO[]) => {
  671. deviceIds.value = selection.map((item) => item.id);
  672. form.value.deviceIds = deviceIds.value;
  673. };
  674. const handleSelectItem = (selection: ItemVO[]) => {
  675. itemIds.value = selection.map((item) => item.id);
  676. form.value.itemIds = itemIds.value;
  677. };
  678. const handleSelectionMinioChange = (selection: MinioDataVO[]) => {
  679. // 获取当前已选中的 ID 列表
  680. const currentSelectedIds = [...selectedMinioDataIds.value];
  681. // 提取当前选中项的 ID
  682. const newSelectedIds = selection.map(item => item.id);
  683. // 构建新的有序 ID 列表:
  684. // 1. 保留仍然被选中的 ID(保持原有顺序)
  685. // 2. 添加新选中的 ID(按当前 selection 顺序追加)
  686. const orderedIds = [
  687. ...currentSelectedIds.filter(id => newSelectedIds.includes(id)),
  688. ...newSelectedIds.filter(id => !currentSelectedIds.includes(id))
  689. ];
  690. // 更新选中 ID 列表
  691. selectedMinioDataIds.value = orderedIds;
  692. // 绑定到 form.itemIds
  693. form.value.itemIds = orderedIds;
  694. console.log('当前选中的文件:', form.value.itemIds)
  695. }
  696. const handleRadioChange = (row: ItemVO) => {
  697. const itemIds = [row.id];
  698. form.value.itemIds = itemIds;
  699. };
  700. /** 新增按钮操作 */
  701. const handleAdd = () => {
  702. reset();
  703. dialog.visible = true;
  704. dialog.title = '内容发布';
  705. selectedRowId.value = null;
  706. queryParams.value.deviceName = null;
  707. getDeviceList();
  708. };
  709. /** 修改按钮操作 */
  710. const handleUpdate = async (row?: ItemPushVO) => {
  711. reset();
  712. const _id = row?.id || ids.value[0];
  713. const res = await getItemPush(_id);
  714. Object.assign(form.value, res.data);
  715. dialog.visible = true;
  716. dialog.title = '修改内容发布';
  717. await getDeviceList();
  718. };
  719. /** 提交按钮 */
  720. const submitForm = () => {
  721. itemPushFormRef.value?.validate(async (valid: boolean) => {
  722. if (valid) {
  723. buttonLoading.value = true;
  724. if (form.value.id) {
  725. await updateItemPush(form.value).finally(() => (buttonLoading.value = false));
  726. } else {
  727. // 校验时间冲突
  728. const resTime = await validateTime(form.value).finally(() => (buttonLoading.value = false));
  729. if (resTime.data.code !== 200) {
  730. await proxy?.$modal.confirm("排期时间存在冲突,是否覆盖之前排期").finally(() => (buttonLoading.value = false));
  731. console.log(resTime.data)
  732. await addItemPush(form.value).finally(() => (buttonLoading.value = false));
  733. } else {
  734. await addItemPush(form.value).finally(() => (buttonLoading.value = false));
  735. }
  736. }
  737. proxy?.$modal.msgSuccess('操作成功');
  738. dialog.visible = false;
  739. await getList();
  740. await getStatistics();
  741. }
  742. });
  743. };
  744. /** 删除按钮操作 */
  745. const handleDelete = async (row?: ItemPushVO) => {
  746. const _ids = row?.id || ids.value;
  747. await proxy?.$modal.confirm('是否确认删除已选择的数据项?').finally(() => (loading.value = false));
  748. await delItemPush(_ids);
  749. proxy?.$modal.msgSuccess('删除成功');
  750. await getList();
  751. await getStatistics();
  752. };
  753. const handleReview = async (row?: ItemPushVO) => {
  754. const id = row?.id;
  755. if (row.status !== 'draft') {
  756. proxy?.$modal.msgError('只有未提交状态可以提交审核');
  757. return;
  758. }
  759. await proxy?.$modal.confirm('是否确认提交审核名称为"' + row.name + '"的数据项?').finally(() => (loading.value = false));
  760. await reviewItemPush(id);
  761. proxy?.$modal.msgSuccess('提交成功');
  762. await getList();
  763. };
  764. /** 导出按钮操作 */
  765. const handleExport = () => {
  766. proxy?.download(
  767. 'source/itemPush/export',
  768. {
  769. ...queryParams.value
  770. },
  771. `itemPush_${new Date().getTime()}.xlsx`
  772. );
  773. };
  774. watch(() => deviceDialog.visible, (newValue) => {
  775. if (!newValue) {
  776. getList();
  777. getStatistics();
  778. }
  779. });
  780. onMounted(() => {
  781. getList();
  782. getStatistics();
  783. getItemList();
  784. });
  785. </script>
  786. <style scoped>
  787. .time-period {
  788. display: flex;
  789. align-items: center;
  790. margin-bottom: 10px;
  791. }
  792. .time-period span {
  793. margin: 0 10px;
  794. }
  795. .dialog-footer {
  796. text-align: right;
  797. }
  798. .statistic-card {
  799. border-radius: 1px;
  800. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.08);
  801. border: 1px solid #ebeef5;
  802. padding: 10px 0;
  803. height: 100px;
  804. background: #fff;
  805. width: calc(100% - 3px);
  806. }
  807. .statistic-item {
  808. text-align: center;
  809. padding: 10px 0;
  810. }
  811. .statistic-title {
  812. display: flex;
  813. align-items: center;
  814. justify-content: center;
  815. gap: 8px;
  816. font-size: 14px;
  817. color: #606266;
  818. font-weight: 500;
  819. margin-bottom: 8px;
  820. }
  821. .statistic-icon {
  822. width: 40px;
  823. height: 40px;
  824. border-radius: 10px;
  825. display: flex;
  826. align-items: center;
  827. justify-content: center;
  828. margin: 0 auto 10px;
  829. color: white;
  830. font-size: 18px;
  831. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
  832. }
  833. .total-icon {
  834. background: linear-gradient(135deg, #409eff, #2282ff);
  835. }
  836. .carousel-icon {
  837. background: linear-gradient(135deg, #e6a23c, #d48c1f);
  838. }
  839. .split-icon {
  840. background: linear-gradient(135deg, #67c23a, #48ab1f);
  841. }
  842. .material-icon {
  843. background: linear-gradient(135deg, #909399, #73767a);
  844. }
  845. :deep(.statistic-item .el-statistic__content) {
  846. font-size: 24px;
  847. font-weight: 700;
  848. color: #303133;
  849. }
  850. /* 响应式设计 */
  851. @media (max-width: 1200px) {
  852. :deep(.el-col) {
  853. flex: 0 0 50%;
  854. max-width: 50%;
  855. margin-bottom: 10px;
  856. }
  857. :deep(.el-row) {
  858. flex-wrap: wrap;
  859. }
  860. .statistic-card {
  861. padding: 10px 0;
  862. }
  863. }
  864. @media (max-width: 768px) {
  865. :deep(.el-col) {
  866. flex: 0 0 100%;
  867. max-width: 100%;
  868. }
  869. .statistic-title {
  870. font-size: 13px;
  871. }
  872. .statistic-icon {
  873. width: 36px;
  874. height: 36px;
  875. font-size: 16px;
  876. }
  877. :deep(.statistic-item .el-statistic__content) {
  878. font-size: 20px;
  879. }
  880. }
  881. </style>