123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551 |
- <template>
- <div class="app-container">
- <el-form
- v-show="showSearch"
- ref="queryForm"
- :model="queryParams"
- size="small"
- :inline="true"
- class="app-container--search"
- >
- <el-form-item label="发生时间">
- <el-date-picker
- v-model="daterangeWarnTime"
- style="width: 240px"
- value-format="yyyy-MM-dd HH:mm:ss"
- type="daterange"
- range-separator="-"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- :default-time="['00:00:00', '23:59:59']"
- />
- </el-form-item>
- <el-form-item label="商品名称" prop="goodsSkuName">
- <el-input
- v-model="queryParams.goodsSkuName"
- placeholder="请输入商品名称"
- clearable
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item label="商品编号" prop="goodsSkuSn">
- <el-input
- v-model="queryParams.goodsSkuSn"
- placeholder="请输入商品编号"
- clearable
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item label="处理状态" prop="status">
- <el-select
- v-model="queryParams.status"
- placeholder="请选择处理状态"
- clearable
- >
- <el-option
- v-for="dict in dict.type.zs_operation_status"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button
- type="primary"
- icon="el-icon-search"
- size="mini"
- @click="handleQuery"
- >搜索</el-button>
- <el-button
- icon="el-icon-refresh"
- size="mini"
- @click="resetQuery"
- >重置</el-button>
- </el-form-item>
- </el-form>
-
- <el-row :gutter="10" class="mb8">
- <!--<el-col :span="1.5">
- <el-button
- type="primary"
- plain
- icon="el-icon-plus"
- size="mini"
- @click="handleAdd"
- v-hasPermi="['system:operationWarnresult:add']"
- >新增</el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="success"
- plain
- icon="el-icon-edit"
- size="mini"
- :disabled="single"
- @click="handleUpdate"
- v-hasPermi="['system:operationWarnresult:edit']"
- >修改</el-button>
- </el-col>-->
- <el-col :span="1.5">
- <el-button
- v-hasPermi="['system:operationWarnresult:remove']"
- type="danger"
- plain
- icon="el-icon-delete"
- size="mini"
- :disabled="multiple"
- @click="handleDelete"
- >删除</el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- v-hasPermi="['system:operationWarnresult:export']"
- type="warning"
- plain
- icon="el-icon-download"
- size="mini"
- @click="handleExport"
- >导出</el-button>
- </el-col>
- <right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
- </el-row>
-
- <el-table
- v-loading="loading"
- :data="operationWarnresultList"
- @selection-change="handleSelectionChange"
- >
- <el-table-column type="selection" width="55" align="center" />
- <el-table-column v-if="false" label="主键ID" align="center" prop="id" />
- <el-table-column
- label="发生时间"
- align="center"
- prop="warnTime"
- width="180"
- >
- <template slot-scope="scope">
- <span>{{
- parseTime(scope.row.warnTime, '{y}-{m}-{d} {h}:{i}:{s}')
- }}</span>
- </template>
- </el-table-column>
- <el-table-column label="预警商品" align="center" prop="goodsSkuName">
- <template slot-scope="scope">
- <div class="goods--info">
- <el-link
- type="primary"
- :underline="false"
- :href="scope.row.goodsSkuUrl"
- target="_blank"
- :title="scope.row.goodsSkuName"
- >
- {{ scope.row.goodsSkuName }}
- </el-link>
- <em
- style="
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- "
- :title="scope.row.remark"
- >{{ scope.row.remark }}</em>
- <em>{{ scope.row.goodsSkuSn }}</em>
- <em>¥{{ scope.row.initPrice }}</em>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- width="150"
- label="预警价格"
- align="center"
- prop="initPrice"
- >
- <template slot-scope="scope">
- <div
- v-if="scope.row.curPrice"
- class="price--info"
- style="text-align: left; display: flex"
- >
- <span
- style="
- display: inline-flex;
- align-items: center;
- justify-content: center;
- text-align: center;
- width: 30px;
- padding: 2px;
- "
- >
- <i
- v-if="
- parseFloat(scope.row.curPrice) >
- parseFloat(scope.row.initPrice)
- "
- class="el-icon-top"
- style="color: green; font-size: 16px"
- />
- <i
- v-else-if="
- parseFloat(scope.row.curPrice) ===
- parseFloat(scope.row.initPrice)
- "
- class="el-icon-minus"
- style="color: #999; font-size: 16px"
- />
- <i
- v-else
- class="el-icon-bottom"
- style="color: red; font-size: 16px"
- />
- </span>
-
- <span
- style="color: #303133; font-size: 14px"
- >¥{{ scope.row.curPrice }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- width="120"
- label="通知方式"
- align="center"
- prop="warnTypes"
- >
- <template slot-scope="scope">
- <dict-tag
- :options="dict.type.zs_operation_warn_types"
- :value="scope.row.warnTypes"
- />
- </template>
- </el-table-column>
- <el-table-column width="120" label="平台" align="center" prop="platform">
- <template slot-scope="scope">
- <dict-tag
- :options="dict.type.zs_operation_platform"
- :value="scope.row.platform"
- />
- </template>
- </el-table-column>
- <el-table-column
- label="操作"
- align="center"
- width="220"
- class-name="small-padding fixed-width"
- >
- <template slot-scope="scope">
- <el-button
- v-if="scope.row.status == 0"
- v-hasPermi="['system:operationWarnresult:edit']"
- size="mini"
- type="text"
- icon="el-icon-circle-check"
- @click="handleDispose(scope.row)"
- >处理</el-button>
-
- <span
- v-else
- class="text-info"
- style="margin-right: 10px"
- >已处理</span>
-
- <el-button
- size="mini"
- type="text"
- icon="el-icon-camera"
- @click="handleView(scope.row)"
- >快照</el-button>
-
- <el-button
- v-hasPermi="['system:operationWarnresult:remove']"
- size="mini"
- type="text"
- icon="el-icon-delete"
- @click="handleDelete(scope.row)"
- >删除</el-button>
- </template>
- </el-table-column>
- </el-table>
-
- <pagination
- v-show="total > 0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
-
- <!-- 添加或修改预警结果对话框 -->
- <el-dialog :title="title" :visible.sync="open" width="960px" append-to-body>
- <div class="warn-result" v-html="warnResult" />
- </el-dialog>
- </div>
- </template>
-
- <script>
- import {
- listOperationWarnresult,
- getOperationWarnresult,
- delOperationWarnresult,
- addOperationWarnresult,
- updateOperationWarnresult
- } from '@/api/system/operationWarnresult'
-
- export default {
- name: 'OperationWarnresult',
- dicts: [
- 'zs_operation_warn_types',
- 'zs_operation_status',
- 'zs_operation_compare_status',
- 'zs_operation_platform'
- ],
- data() {
- return {
- // 按钮loading
- buttonLoading: false,
- // 遮罩层
- loading: true,
- // 选中数组
- ids: [],
- // 非单个禁用
- single: true,
- // 非多个禁用
- multiple: true,
- // 显示搜索条件
- showSearch: true,
- // 总条数
- total: 0,
- // 预警结果表格数据
- operationWarnresultList: [],
- // 弹出层标题
- title: '',
- // 是否显示弹出层
- open: false,
- // 图片快照时间范围
- daterangeWarnTime: [],
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- warnTime: undefined,
- goodsSkuName: undefined,
- goodsSkuSn: undefined,
- status: undefined,
- compareStatus: undefined
- },
- // 表单参数
- form: {},
- // 预警结果
- warnResult: '',
- // 表单校验
- rules: {
- snapshotUrl: [
- { required: true, message: '图片快照不能为空', trigger: 'blur' }
- ]
- }
- }
- },
- created() {
- this.getList()
- },
- methods: {
- /** 查询预警结果列表 */
- getList() {
- this.loading = true
- this.queryParams.params = {}
- if (this.daterangeWarnTime != null && this.daterangeWarnTime != '') {
- this.queryParams.params['beginWarnTime'] = this.daterangeWarnTime[0]
- this.queryParams.params['endWarnTime'] = this.daterangeWarnTime[1]
- }
- listOperationWarnresult(this.queryParams).then((response) => {
- this.operationWarnresultList = response.rows
- this.total = response.total
- this.loading = false
- })
- },
- // 取消按钮
- cancel() {
- this.open = false
- this.reset()
- },
- // 表单重置
- reset() {
- this.form = {
- id: undefined,
- warnTime: undefined,
- goodsSkuName: undefined,
- goodsSkuSn: undefined,
- initPrice: undefined,
- curPrice: undefined,
- priceChangeRatio: undefined,
- warnTypes: undefined,
- warnContent: undefined,
- status: undefined,
- snapshotUrl: undefined
- }
- this.resetForm('form')
- },
- /** 处理按钮操作 */
- handleDispose(row) {
- const _html = `
- <p class="warn-result-text">预警商品:<a href="${row.goodsSkuUrl}" target="_blank">${row.goodsSkuName}</a></p>
- <p class="warn-result-text">预警价格:${row.curPrice}</p>
- <p class="warn-result-text">预警时间:${row.warnTime}</p>
- <p class="warn-result-text">预警平台:${row.platform}</p>
- <p class="warn-result-text">预警备注:${row.remark}</p>
- <p class="warn-result-text">预警快照:<a href="${row.snapshotUrl}" target="_blank">点击查看</a></p>
- <p class="warn-result-tips">注:如果点击“稍后处理”,则预警结果将不会被处理,预警状态将不会被修改。如果点击“立即处理”,则当前商品基准价格将会被修改为预警价格,价格监控按照新的基准价格进行监控。</p>
- `
- this.$confirm(_html, '提示', {
- confirmButtonText: '立即处理',
- cancelButtonText: '稍后处理',
- dangerouslyUseHTMLString: true,
- closeOnClickModal: false,
- closeOnPressEscape: false,
- showClose: false,
- customClass: 'warn-result-message'
- }).then(() => {
- this.loading = true
- row.status = 1
- updateOperationWarnresult(row)
- .then((response) => {
- this.$modal.msgSuccess('处理成功')
- this.open = false
- this.getList()
- })
- .finally(() => {
- this.loading = false
- })
- })
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNum = 1
- this.getList()
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.daterangeWarnTime = []
- this.resetForm('queryForm')
- this.handleQuery()
- },
- // 多选框选中数据
- handleSelectionChange(selection) {
- this.ids = selection.map((item) => item.id)
- this.single = selection.length !== 1
- this.multiple = !selection.length
- },
- handleView(row) {
- // 将状态设置为已处理
- this.open = true
- this.title = '预警结果'
- this.warnResult = row.warnContent
- },
- /** 提交按钮 */
- submitForm() {
- this.$refs['form'].validate((valid) => {
- if (valid) {
- this.buttonLoading = true
- if (this.form.id != null) {
- updateOperationWarnresult(this.form)
- .then((response) => {
- this.$modal.msgSuccess('修改成功')
- this.open = false
- this.getList()
- })
- .finally(() => {
- this.buttonLoading = false
- })
- } else {
- addOperationWarnresult(this.form)
- .then((response) => {
- this.$modal.msgSuccess('新增成功')
- this.open = false
- this.getList()
- })
- .finally(() => {
- this.buttonLoading = false
- })
- }
- }
- })
- },
- /** 删除按钮操作 */
- handleDelete(row) {
- const ids = row.id || this.ids
- this.$modal
- .confirm('是否确认删除预警结果编号为"' + ids + '"的数据项?')
- .then(() => {
- this.loading = true
- return delOperationWarnresult(ids)
- })
- .then(() => {
- this.loading = false
- this.getList()
- this.$modal.msgSuccess('删除成功')
- })
- .catch(() => {})
- .finally(() => {
- this.loading = false
- })
- },
- /** 导出按钮操作 */
- handleExport() {
- this.download(
- 'system/operationWarnresult/export',
- {
- ...this.queryParams
- },
- `operationWarnresult_${new Date().getTime()}.xlsx`
- )
- }
- }
- }
- </script>
- <style lang="scss">
- .warn-result table {
- width: 100% !important;
- }
- .warn-result table td a {
- display: none;
- }
- .warn-result table img {
- width: 100% !important;
- }
- .warn-result-message {
- .warn-result-text {
- font-size: 14px;
- color: #303133;
- a {
- color: #409eff;
- text-decoration: underline;
- }
- }
- .warn-result-tips {
- font-size: 12px;
- color: #999;
- margin-top: 10px;
- }
- }
- </style>
- <style lang="scss" scoped>
- .goods--info {
- display: flex;
- flex-direction: column;
- justify-content: center;
- text-align: left;
- .el-link {
- font-size: 14px;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- line-clamp: 2;
- -webkit-box-orient: vertical;
- overflow: hidden;
- }
- em {
- font-size: 12px;
- color: #999;
- font-style: normal;
- }
- }
- </style>
|