Digital Office Automation System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. v-show="showSearch"
  5. ref="queryForm"
  6. :model="queryParams"
  7. size="small"
  8. :inline="true"
  9. class="app-container--search"
  10. >
  11. <el-form-item label="发生时间">
  12. <el-date-picker
  13. v-model="daterangeWarnTime"
  14. style="width: 240px"
  15. value-format="yyyy-MM-dd HH:mm:ss"
  16. type="daterange"
  17. range-separator="-"
  18. start-placeholder="开始日期"
  19. end-placeholder="结束日期"
  20. :default-time="['00:00:00', '23:59:59']"
  21. />
  22. </el-form-item>
  23. <el-form-item label="商品名称" prop="goodsSkuName">
  24. <el-input
  25. v-model="queryParams.goodsSkuName"
  26. placeholder="请输入商品名称"
  27. clearable
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="商品编号" prop="goodsSkuSn">
  32. <el-input
  33. v-model="queryParams.goodsSkuSn"
  34. placeholder="请输入商品编号"
  35. clearable
  36. @keyup.enter.native="handleQuery"
  37. />
  38. </el-form-item>
  39. <el-form-item label="处理状态" prop="status">
  40. <el-select
  41. v-model="queryParams.status"
  42. placeholder="请选择处理状态"
  43. clearable
  44. >
  45. <el-option
  46. v-for="dict in dict.type.zs_operation_status"
  47. :key="dict.value"
  48. :label="dict.label"
  49. :value="dict.value"
  50. />
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item>
  54. <el-button
  55. type="primary"
  56. icon="el-icon-search"
  57. size="mini"
  58. @click="handleQuery"
  59. >搜索</el-button>
  60. <el-button
  61. icon="el-icon-refresh"
  62. size="mini"
  63. @click="resetQuery"
  64. >重置</el-button>
  65. </el-form-item>
  66. </el-form>
  67. <el-row :gutter="10" class="mb8">
  68. <!--<el-col :span="1.5">
  69. <el-button
  70. type="primary"
  71. plain
  72. icon="el-icon-plus"
  73. size="mini"
  74. @click="handleAdd"
  75. v-hasPermi="['system:operationWarnresult:add']"
  76. >新增</el-button>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-button
  80. type="success"
  81. plain
  82. icon="el-icon-edit"
  83. size="mini"
  84. :disabled="single"
  85. @click="handleUpdate"
  86. v-hasPermi="['system:operationWarnresult:edit']"
  87. >修改</el-button>
  88. </el-col>-->
  89. <el-col :span="1.5">
  90. <el-button
  91. v-hasPermi="['system:operationWarnresult:remove']"
  92. type="danger"
  93. plain
  94. icon="el-icon-delete"
  95. size="mini"
  96. :disabled="multiple"
  97. @click="handleDelete"
  98. >删除</el-button>
  99. </el-col>
  100. <el-col :span="1.5">
  101. <el-button
  102. v-hasPermi="['system:operationWarnresult:export']"
  103. type="warning"
  104. plain
  105. icon="el-icon-download"
  106. size="mini"
  107. @click="handleExport"
  108. >导出</el-button>
  109. </el-col>
  110. <right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
  111. </el-row>
  112. <el-table
  113. v-loading="loading"
  114. :data="operationWarnresultList"
  115. @selection-change="handleSelectionChange"
  116. >
  117. <el-table-column type="selection" width="55" align="center" />
  118. <el-table-column v-if="false" label="主键ID" align="center" prop="id" />
  119. <el-table-column
  120. label="发生时间"
  121. align="center"
  122. prop="warnTime"
  123. width="180"
  124. >
  125. <template slot-scope="scope">
  126. <span>{{
  127. parseTime(scope.row.warnTime, '{y}-{m}-{d} {h}:{i}:{s}')
  128. }}</span>
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="预警商品" align="center" prop="goodsSkuName">
  132. <template slot-scope="scope">
  133. <div class="goods--info">
  134. <el-link
  135. type="primary"
  136. :underline="false"
  137. :href="scope.row.goodsSkuUrl"
  138. target="_blank"
  139. :title="scope.row.goodsSkuName"
  140. >
  141. {{ scope.row.goodsSkuName }}
  142. </el-link>
  143. <em
  144. style="
  145. white-space: nowrap;
  146. overflow: hidden;
  147. text-overflow: ellipsis;
  148. "
  149. :title="scope.row.remark"
  150. >{{ scope.row.remark }}</em>
  151. <em>{{ scope.row.goodsSkuSn }}</em>
  152. <em>¥{{ scope.row.initPrice }}</em>
  153. </div>
  154. </template>
  155. </el-table-column>
  156. <el-table-column
  157. width="150"
  158. label="预警价格"
  159. align="center"
  160. prop="initPrice"
  161. >
  162. <template slot-scope="scope">
  163. <div
  164. v-if="scope.row.curPrice"
  165. class="price--info"
  166. style="text-align: left; display: flex"
  167. >
  168. <span
  169. style="
  170. display: inline-flex;
  171. align-items: center;
  172. justify-content: center;
  173. text-align: center;
  174. width: 30px;
  175. padding: 2px;
  176. "
  177. >
  178. <i
  179. v-if="
  180. parseFloat(scope.row.curPrice) >
  181. parseFloat(scope.row.initPrice)
  182. "
  183. class="el-icon-top"
  184. style="color: green; font-size: 16px"
  185. />
  186. <i
  187. v-else-if="
  188. parseFloat(scope.row.curPrice) ===
  189. parseFloat(scope.row.initPrice)
  190. "
  191. class="el-icon-minus"
  192. style="color: #999; font-size: 16px"
  193. />
  194. <i
  195. v-else
  196. class="el-icon-bottom"
  197. style="color: red; font-size: 16px"
  198. />
  199. </span>
  200. <span
  201. style="color: #303133; font-size: 14px"
  202. >¥{{ scope.row.curPrice }}</span>
  203. </div>
  204. </template>
  205. </el-table-column>
  206. <el-table-column
  207. width="120"
  208. label="通知方式"
  209. align="center"
  210. prop="warnTypes"
  211. >
  212. <template slot-scope="scope">
  213. <dict-tag
  214. :options="dict.type.zs_operation_warn_types"
  215. :value="scope.row.warnTypes"
  216. />
  217. </template>
  218. </el-table-column>
  219. <el-table-column width="120" label="平台" align="center" prop="platform">
  220. <template slot-scope="scope">
  221. <dict-tag
  222. :options="dict.type.zs_operation_platform"
  223. :value="scope.row.platform"
  224. />
  225. </template>
  226. </el-table-column>
  227. <el-table-column
  228. label="操作"
  229. align="center"
  230. width="220"
  231. class-name="small-padding fixed-width"
  232. >
  233. <template slot-scope="scope">
  234. <el-button
  235. v-if="scope.row.status == 0"
  236. v-hasPermi="['system:operationWarnresult:edit']"
  237. size="mini"
  238. type="text"
  239. icon="el-icon-circle-check"
  240. @click="handleDispose(scope.row)"
  241. >处理</el-button>
  242. <span
  243. v-else
  244. class="text-info"
  245. style="margin-right: 10px"
  246. >已处理</span>
  247. <el-button
  248. size="mini"
  249. type="text"
  250. icon="el-icon-camera"
  251. @click="handleView(scope.row)"
  252. >快照</el-button>
  253. <el-button
  254. v-hasPermi="['system:operationWarnresult:remove']"
  255. size="mini"
  256. type="text"
  257. icon="el-icon-delete"
  258. @click="handleDelete(scope.row)"
  259. >删除</el-button>
  260. </template>
  261. </el-table-column>
  262. </el-table>
  263. <pagination
  264. v-show="total > 0"
  265. :total="total"
  266. :page.sync="queryParams.pageNum"
  267. :limit.sync="queryParams.pageSize"
  268. @pagination="getList"
  269. />
  270. <!-- 添加或修改预警结果对话框 -->
  271. <el-dialog :title="title" :visible.sync="open" width="960px" append-to-body>
  272. <div class="warn-result" v-html="warnResult" />
  273. </el-dialog>
  274. </div>
  275. </template>
  276. <script>
  277. import {
  278. listOperationWarnresult,
  279. getOperationWarnresult,
  280. delOperationWarnresult,
  281. addOperationWarnresult,
  282. updateOperationWarnresult
  283. } from '@/api/system/operationWarnresult'
  284. export default {
  285. name: 'OperationWarnresult',
  286. dicts: [
  287. 'zs_operation_warn_types',
  288. 'zs_operation_status',
  289. 'zs_operation_compare_status',
  290. 'zs_operation_platform'
  291. ],
  292. data() {
  293. return {
  294. // 按钮loading
  295. buttonLoading: false,
  296. // 遮罩层
  297. loading: true,
  298. // 选中数组
  299. ids: [],
  300. // 非单个禁用
  301. single: true,
  302. // 非多个禁用
  303. multiple: true,
  304. // 显示搜索条件
  305. showSearch: true,
  306. // 总条数
  307. total: 0,
  308. // 预警结果表格数据
  309. operationWarnresultList: [],
  310. // 弹出层标题
  311. title: '',
  312. // 是否显示弹出层
  313. open: false,
  314. // 图片快照时间范围
  315. daterangeWarnTime: [],
  316. // 查询参数
  317. queryParams: {
  318. pageNum: 1,
  319. pageSize: 10,
  320. warnTime: undefined,
  321. goodsSkuName: undefined,
  322. goodsSkuSn: undefined,
  323. status: undefined,
  324. compareStatus: undefined
  325. },
  326. // 表单参数
  327. form: {},
  328. // 预警结果
  329. warnResult: '',
  330. // 表单校验
  331. rules: {
  332. snapshotUrl: [
  333. { required: true, message: '图片快照不能为空', trigger: 'blur' }
  334. ]
  335. }
  336. }
  337. },
  338. created() {
  339. this.getList()
  340. },
  341. methods: {
  342. /** 查询预警结果列表 */
  343. getList() {
  344. this.loading = true
  345. this.queryParams.params = {}
  346. if (this.daterangeWarnTime != null && this.daterangeWarnTime != '') {
  347. this.queryParams.params['beginWarnTime'] = this.daterangeWarnTime[0]
  348. this.queryParams.params['endWarnTime'] = this.daterangeWarnTime[1]
  349. }
  350. listOperationWarnresult(this.queryParams).then((response) => {
  351. this.operationWarnresultList = response.rows
  352. this.total = response.total
  353. this.loading = false
  354. })
  355. },
  356. // 取消按钮
  357. cancel() {
  358. this.open = false
  359. this.reset()
  360. },
  361. // 表单重置
  362. reset() {
  363. this.form = {
  364. id: undefined,
  365. warnTime: undefined,
  366. goodsSkuName: undefined,
  367. goodsSkuSn: undefined,
  368. initPrice: undefined,
  369. curPrice: undefined,
  370. priceChangeRatio: undefined,
  371. warnTypes: undefined,
  372. warnContent: undefined,
  373. status: undefined,
  374. snapshotUrl: undefined
  375. }
  376. this.resetForm('form')
  377. },
  378. /** 处理按钮操作 */
  379. handleDispose(row) {
  380. const _html = `
  381. <p class="warn-result-text">预警商品:<a href="${row.goodsSkuUrl}" target="_blank">${row.goodsSkuName}</a></p>
  382. <p class="warn-result-text">预警价格:${row.curPrice}</p>
  383. <p class="warn-result-text">预警时间:${row.warnTime}</p>
  384. <p class="warn-result-text">预警平台:${row.platform}</p>
  385. <p class="warn-result-text">预警备注:${row.remark}</p>
  386. <p class="warn-result-text">预警快照:<a href="${row.snapshotUrl}" target="_blank">点击查看</a></p>
  387. <p class="warn-result-tips">注:如果点击“稍后处理”,则预警结果将不会被处理,预警状态将不会被修改。如果点击“立即处理”,则当前商品基准价格将会被修改为预警价格,价格监控按照新的基准价格进行监控。</p>
  388. `
  389. this.$confirm(_html, '提示', {
  390. confirmButtonText: '立即处理',
  391. cancelButtonText: '稍后处理',
  392. dangerouslyUseHTMLString: true,
  393. closeOnClickModal: false,
  394. closeOnPressEscape: false,
  395. showClose: false,
  396. customClass: 'warn-result-message'
  397. }).then(() => {
  398. this.loading = true
  399. row.status = 1
  400. updateOperationWarnresult(row)
  401. .then((response) => {
  402. this.$modal.msgSuccess('处理成功')
  403. this.open = false
  404. this.getList()
  405. })
  406. .finally(() => {
  407. this.loading = false
  408. })
  409. })
  410. },
  411. /** 搜索按钮操作 */
  412. handleQuery() {
  413. this.queryParams.pageNum = 1
  414. this.getList()
  415. },
  416. /** 重置按钮操作 */
  417. resetQuery() {
  418. this.daterangeWarnTime = []
  419. this.resetForm('queryForm')
  420. this.handleQuery()
  421. },
  422. // 多选框选中数据
  423. handleSelectionChange(selection) {
  424. this.ids = selection.map((item) => item.id)
  425. this.single = selection.length !== 1
  426. this.multiple = !selection.length
  427. },
  428. handleView(row) {
  429. // 将状态设置为已处理
  430. this.open = true
  431. this.title = '预警结果'
  432. this.warnResult = row.warnContent
  433. },
  434. /** 提交按钮 */
  435. submitForm() {
  436. this.$refs['form'].validate((valid) => {
  437. if (valid) {
  438. this.buttonLoading = true
  439. if (this.form.id != null) {
  440. updateOperationWarnresult(this.form)
  441. .then((response) => {
  442. this.$modal.msgSuccess('修改成功')
  443. this.open = false
  444. this.getList()
  445. })
  446. .finally(() => {
  447. this.buttonLoading = false
  448. })
  449. } else {
  450. addOperationWarnresult(this.form)
  451. .then((response) => {
  452. this.$modal.msgSuccess('新增成功')
  453. this.open = false
  454. this.getList()
  455. })
  456. .finally(() => {
  457. this.buttonLoading = false
  458. })
  459. }
  460. }
  461. })
  462. },
  463. /** 删除按钮操作 */
  464. handleDelete(row) {
  465. const ids = row.id || this.ids
  466. this.$modal
  467. .confirm('是否确认删除预警结果编号为"' + ids + '"的数据项?')
  468. .then(() => {
  469. this.loading = true
  470. return delOperationWarnresult(ids)
  471. })
  472. .then(() => {
  473. this.loading = false
  474. this.getList()
  475. this.$modal.msgSuccess('删除成功')
  476. })
  477. .catch(() => {})
  478. .finally(() => {
  479. this.loading = false
  480. })
  481. },
  482. /** 导出按钮操作 */
  483. handleExport() {
  484. this.download(
  485. 'system/operationWarnresult/export',
  486. {
  487. ...this.queryParams
  488. },
  489. `operationWarnresult_${new Date().getTime()}.xlsx`
  490. )
  491. }
  492. }
  493. }
  494. </script>
  495. <style lang="scss">
  496. .warn-result table {
  497. width: 100% !important;
  498. }
  499. .warn-result table td a {
  500. display: none;
  501. }
  502. .warn-result table img {
  503. width: 100% !important;
  504. }
  505. .warn-result-message {
  506. .warn-result-text {
  507. font-size: 14px;
  508. color: #303133;
  509. a {
  510. color: #409eff;
  511. text-decoration: underline;
  512. }
  513. }
  514. .warn-result-tips {
  515. font-size: 12px;
  516. color: #999;
  517. margin-top: 10px;
  518. }
  519. }
  520. </style>
  521. <style lang="scss" scoped>
  522. .goods--info {
  523. display: flex;
  524. flex-direction: column;
  525. justify-content: center;
  526. text-align: left;
  527. .el-link {
  528. font-size: 14px;
  529. display: -webkit-box;
  530. -webkit-line-clamp: 2;
  531. line-clamp: 2;
  532. -webkit-box-orient: vertical;
  533. overflow: hidden;
  534. }
  535. em {
  536. font-size: 12px;
  537. color: #999;
  538. font-style: normal;
  539. }
  540. }
  541. </style>