From 4eac422e52a4d28fb651b75d0f054697c7a2c0fa Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期一, 09 二月 2026 15:14:13 +0800
Subject: [PATCH] 优化

---
 admin/src/components/business/OperaGoodsShopWindow.vue |  301 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 301 insertions(+), 0 deletions(-)

diff --git a/admin/src/components/business/OperaGoodsShopWindow.vue b/admin/src/components/business/OperaGoodsShopWindow.vue
new file mode 100644
index 0000000..0030c5c
--- /dev/null
+++ b/admin/src/components/business/OperaGoodsShopWindow.vue
@@ -0,0 +1,301 @@
+<template>
+  <GlobalWindow
+      :title="title"
+      width="100%"
+      :visible.sync="visible"
+  >
+    <TableLayout >
+      <!-- 鎼滅储琛ㄥ崟 -->
+      <el-form ref="searchForm" slot="search-form" :model="searchForm"  label-width="10px" style="display: block;" >
+        <el-form-item label="" prop="name" style="display: inline-block;margin-right: 30px;width: 180px">
+          <el-input v-model="searchForm.name" placeholder="鍟嗗搧鍚嶇О" @keypress.enter.native="search"></el-input>
+        </el-form-item>
+        <el-form-item label="" prop="id" style="display: inline-block;margin-right: 30px;;width: 180px">
+          <el-input v-model="searchForm.id" placeholder="鍟嗗搧ID" @keypress.enter.native="search"></el-input>
+        </el-form-item>
+        <el-form-item label="" prop="categoryId" style="display: inline-block;margin-right: 30px;">
+          <!-- 0姝e父 1绂佺敤 -->
+          <el-select
+              v-model="searchForm.categoryId"
+              style="width: 120px"
+              placeholder="鎵�灞炲垎绫�"
+              clearable
+              @change="search"
+          >
+            <el-option
+                v-for="item in labels"
+                :key="item.id"
+                :value="item.id"
+                :label="item.name"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="" prop="brandId" style="display: inline-block;margin-right: 30px;">
+          <!-- 0姝e父 1绂佺敤 -->
+          <el-select
+              v-model="searchForm.brandId"
+              style="width: 120px"
+              placeholder="鎵�灞炲搧鐗�"
+              clearable
+              @change="search"
+          >
+            <el-option
+                v-for="item in brands"
+                :key="item.id"
+                :value="item.id"
+                :label="item.name"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="" prop="status" style="display: inline-block;margin-right: 30px;">
+          <!-- 0姝e父 1绂佺敤 -->
+          <el-select
+              v-model="searchForm.status"
+              style="width: 120px"
+              @change="search"
+              clearable
+              placeholder="涓婁笅鏋剁姸鎬�"
+          >
+            <el-option :key="0" :value="0" label="涓婃灦"></el-option>
+            <el-option :key="1" :value="1" label="涓嬫灦"></el-option>
+          </el-select>
+        </el-form-item>
+        <section>
+          <el-button type="primary" @click="search">鎼滅储</el-button>
+          <el-button @click="reset">閲嶇疆</el-button>
+        </section>
+      </el-form>
+      <!-- 琛ㄦ牸鍜屽垎椤� -->
+      <template v-slot:table-wrap>
+<!--        <ul class="toolbar" >
+          <li><el-button type="primary" icon="el-icon-plus" @click="setPriceBatch"  >鎵归噺瀹氫环</el-button></li>
+        </ul>-->
+        <div :style="'display: flex;height:'+tabelHeight+'px;'">
+        <el-table
+            :height="tabelHeight"
+            v-loading="isWorking.search"
+            :data="tableData.list"
+            stripe
+            border
+            @selection-change="handleSelectionChange"
+        >
+<!--
+          <el-table-column type="selection" width="55"></el-table-column>
+-->
+          <el-table-column prop="imgurl" label="鍟嗗搧淇℃伅" min-width="80px">
+            <template slot-scope="{row}">
+              <el-image style="width: 50px;height: 50px;" v-if="row.imgurl && row.imgurl!=''" :src="row.resourcePath+row.imgurl" :preview-src-list="[row.resourcePath+row.imgurl]"></el-image>
+            </template>
+          </el-table-column>
+          <el-table-column prop="id" label="鍟嗗搧ID" min-width="120px" ></el-table-column>
+          <el-table-column prop="name" label="鍟嗗搧鍚嶇О" min-width="180px" show-overflow-tooltip></el-table-column>
+          <el-table-column prop="categoryName" label="鎵�灞炲垎绫�" min-width="120px"></el-table-column>
+          <el-table-column prop="brandName" label="鎵�灞炲搧鐗�" min-width="120px"></el-table-column>
+          <el-table-column prop="stockNum" label="鍓╀綑搴撳瓨閲�" min-width="100px"></el-table-column>
+          <el-table-column prop="status" label="涓婁笅鏋剁姸鎬�" min-width="100px"   align="center">
+            <template slot-scope="{row}">
+              <span  v-if="row.status ==1" class="red">宸蹭笅鏋�</span>
+              <span v-else class="green">宸蹭笂鏋�</span>
+            </template>
+          </el-table-column>
+          <el-table-column prop="price" label="灞曠ず浠锋牸" min-width="100px" align="center"></el-table-column>
+          <el-table-column prop="skuPrice" label="閿�鍞环(鍏�)"  fixed="right" min-width="100px" align="center">
+            <template slot-scope="{row}">
+              <span  class="orange">{{ row.skuPrice }}</span>
+            </template>
+          </el-table-column>
+          <el-table-column prop="shopPrice" label="渚涜揣浠�(鍏�)" align="center" min-width="100px" fixed="right">
+            <template slot-scope="scope">
+              <el-input v-if="scope.row.isPriceSelected" v-model="scope.row.shopPrice"
+                        @focus="focusEvent(scope.row,scope.$index,scope.column)"
+                        @blur="blurEvent(scope.row,scope.$index,scope.column)" v-focus></el-input>
+              <p :style="'cursor: pointer;'+((scope.row.skuPrice||0) <= (scope.row.shopPrice||0)?'color: red':'')+';'" class="blue" title="鐐瑰嚮缂栬緫" @click="cellClick(scope.row, scope.column)" v-else>
+                {{scope.row.shopPrice || '鏈缃�' }}
+                <i v-if="(scope.row.skuPrice||0) <= (scope.row.shopPrice||0)" class="el-icon-warning" style="color: red"></i>
+              </p>
+            </template>
+          </el-table-column>
+<!--          <el-table-column
+              label="鎿嶄綔"
+              min-width="160"
+              fixed="right"
+          >
+            <template slot-scope="{row}">
+              <el-button type="text" v-permissions="['business:goods:update']" @click="setPrice(row)">璁剧疆浠锋牸</el-button>
+            </template>
+          </el-table-column>-->
+        </el-table>
+        <pagination
+            @size-change="handleSizeChange"
+            @current-change="handlePageChange"
+            :pagination="tableData.pagination"
+        >
+        </pagination>
+        </div>
+      </template>
+    </TableLayout>
+    <template  v-slot:footer>
+      <el-button @click="visible=false">杩斿洖</el-button>
+    </template>
+  </GlobalWindow>
+</template>
+
+<script>
+import GlobalWindow from '@/components/common/GlobalWindow'
+import BaseTable from '@/components/base/BaseTable'
+import TableLayout from '@/layouts/TableLayout'
+import Pagination from '@/components/common/Pagination'
+import { findAll as labelList } from '@/api/business/labels'
+import { setGoodsPrice } from '@/api/business/shop'
+export default {
+  name: 'OperaShopGoodsWindow',
+  extends: BaseTable,
+  components: { GlobalWindow, TableLayout, Pagination },
+  data () {
+    return {
+      title: '',
+      price: null,
+      visible: false,
+      tabelHeight: null,
+      // 鎼滅储
+      searchForm: {
+        id: '',
+        name: '',
+        shopId: null,
+        categoryId: '',
+        brandId: '',
+        // 绫诲瀷 0骞冲彴鍟嗗煄 1鍜栬眴鍟嗗煄 2鍜栧暋璁″垝鍟嗗搧
+        type: '0', // 骞冲彴鍟嗗搧
+        status: 0,
+        labels: ''
+      },
+      labels: [],
+      brands: []
+    }
+  },
+  mounted () {
+    window.addEventListener('resize', this.handleResize)
+  },
+  beforeDestroy () {
+    window.removeEventListener('resize', this.handleResize)
+  },
+  created: function () {
+    this.config({
+      module: '鍟嗗搧淇℃伅琛�',
+      api: '/business/goods',
+      'field.id': 'id',
+      'field.main': 'id'
+    })
+    this.handleResize()
+    labelList({
+      type: 0 // 鍟嗗搧鍒嗙被
+    }).then(res => {
+      this.labels = res
+    })
+    labelList({
+      type: 1 // 鍟嗗搧鍝佺墝
+    })
+      .then(res => {
+        this.brands = res
+      })
+  },
+  directives: {
+    focus: {
+      inserted: function (el) {
+        el.querySelector('input').focus()
+      }
+    }
+  },
+  methods: {
+    setPrice (row) {
+      if (row.skuPrice == null) {
+        this.$tip.warning('璇峰厛璁剧疆鍟嗗搧閿�鍞环锛�')
+        return
+      }
+      console.log(row)
+    },
+    setPriceBatch () {
+    },
+    handleResize () {
+      this.tabelHeight = window.innerHeight - 400
+    },
+    open (title, info) {
+      this.title = title
+      this.visible = true
+      this.searchForm.shopId = info.id
+      this.search()
+      this.handleResize()
+    },
+    handlePageChange: function (pageIndex) {
+      this.__checkApi()
+      this.tableData.pagination.pageIndex = pageIndex || this.tableData.pagination.pageIndex
+      this.isWorking.search = true
+      this.api.fetchList({
+        page: this.tableData.pagination.pageIndex,
+        capacity: this.tableData.pagination.pageSize,
+        model: this.searchForm,
+        sorts: this.tableData.sorts
+      })
+        .then(data => {
+          (data.records || []).forEach((item) => {
+            item.isPriceSelected = false
+          })
+          this.tableData.list = data.records || []
+          this.tableData.pagination.total = data.total
+          console.log(this.tableData.list)
+        })
+        .catch(e => {
+          this.$tip.apiFailed(e)
+        })
+        .finally(() => {
+          this.isWorking.search = false
+        })
+    },
+    cellClick (row, column) {
+      row.isPriceSelected = !row.isPriceSelected
+    },
+    focusEvent (row, index, column) {
+      row.oldShopsPrice = row.shopPrice
+    },
+    blurEvent (row, curIndex, column) {
+      if ( !row.skuPrice) {
+        this.$tip.error('鍟嗗搧閿�鍞环鏈缃紒')
+        row.isPriceSelected = !row.isPriceSelected
+        row.shopPrice = row.oldShopsPrice// 浠锋牸杩樺師
+        return
+      }
+      if (  row.skuPrice <= row.shopPrice) {
+        this.$tip.error('渚涜揣浠蜂笉鑳藉ぇ浜庨攢鍞环')
+        row.isPriceSelected = !row.isPriceSelected
+        row.shopPrice = row.oldShopsPrice// 浠锋牸杩樺師
+        return
+      }
+      if (row.shopPrice == row.oldShopsPrice) {
+        row.isPriceSelected = !row.isPriceSelected
+        return
+      }
+      setGoodsPrice({
+        id: this.searchForm.shopId,
+        goodsId: row.id,
+        goodsPrice: row.shopPrice
+      }).then(res => {
+        row.oldShopsPrice = row.shopPrice
+        this.$tip.success('淇敼鎴愬姛')
+        this.$emit('success')
+      }).catch(e => {
+        row.shopPrice = row.oldShopsPrice// 浠锋牸杩樺師
+      }).finally(() => {
+        row.isPriceSelected = !row.isPriceSelected
+      })
+    },
+    handleClick (val) {
+    }
+  }
+}
+</script>
+<style scoped>
+.table-pagination{
+  position: fixed !important;
+  bottom: 50px;
+}
+</style>

--
Gitblit v1.9.3