index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. <template>
  2. <div class="app-container">
  3. <div class="tab-container clearfix">
  4. <div class="tab-list fl">
  5. <div class="item" :class="screenForm.type === '' ? 'current':''" @click="changeType('')">全部({{ goodsStateCount.total ? goodsStateCount.total : 0 }})</div>
  6. <div class="item" :class="screenForm.type === 'S' ? 'current':''" @click="changeType('S')">出售中({{ goodsStateCount.csz ? goodsStateCount.csz : 0 }})</div>
  7. <div class="item" :class="screenForm.type === 'O' ? 'current':''" @click="changeType('O')">已售罄({{ goodsStateCount.ysq ? goodsStateCount.ysq : 0 }})</div>
  8. <div class="item" :class="screenForm.type === 'W' ? 'current':''" @click="changeType('W')">仓库中({{ goodsStateCount.ckz ? goodsStateCount.ckz : 0 }})</div>
  9. <div class="item" :class="screenForm.type === 'A' ? 'current':''" @click="changeType('A')">活动中({{ goodsStateCount.hdz ? goodsStateCount.hdz : 0 }})</div>
  10. </div>
  11. <!-- <el-button type="primary" size="small" @click="addOrEdit('add')">添加商品</el-button> -->
  12. </div>
  13. <div class="screen2-container">
  14. <el-row :gutter="20">
  15. <el-col :xs="24" :sm="2" :lg="3" style="opacity: 0;">.</el-col>
  16. <el-col :xs="24" :sm="20" :lg="18">
  17. <el-form ref="form" :model="screenForm" label-width="80px">
  18. <div class="search">
  19. <el-input v-model="screenForm.keyword" placeholder="想快速搜索什么商品呢?输入商品名称,商品id,商品分类都可快速找到" class="input-with-select" clearable @change="getListByScreen">
  20. <el-button slot="append" icon="el-icon-search" @click="getListByScreen"></el-button>
  21. </el-input>
  22. </div>
  23. <div class="screen clearfix">
  24. <el-row :gutter="20">
  25. <el-col :xs="12" :sm="12" :lg="4">
  26. <el-form-item label-width="0">
  27. <el-cascader
  28. v-model="screenForm.classify"
  29. :options="classifyList"
  30. :props="{ label: 'name', value: 'categoryId' }"
  31. size="small"
  32. @change="getListByScreen">
  33. </el-cascader>
  34. <!-- <el-select v-model="screenForm.classify" placeholder="全部" size="small" @change="getListByScreen">
  35. <el-option label="商品分类" value=""></el-option>
  36. <el-option :label="item.name" :value="item.categoryId" v-for="item in classifyList" :key="item.categoryId"></el-option>
  37. </el-select> -->
  38. </el-form-item>
  39. </el-col>
  40. <el-col :xs="12" :sm="12" :lg="4">
  41. <el-form-item label-width="0">
  42. <el-select v-model="screenForm.status" placeholder="全部" size="small" @change="getListByScreen">
  43. <el-option label="上下架状态" value=""></el-option>
  44. <el-option :label="item.label" :value="item.value" v-for="(item, index) in select_status" :key="index"></el-option>
  45. </el-select>
  46. </el-form-item>
  47. </el-col>
  48. <el-col :xs="12" :sm="12" :lg="8">
  49. <el-form-item label="销售价格:" label-width="90px">
  50. <el-input v-model="screenForm.price1" size="small" @change="getListByScreen" clearable ></el-input>
  51. <span>至</span>
  52. <el-input v-model="screenForm.price2" size="small" @change="getListByScreen" clearable ></el-input>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :xs="12" :sm="12" :lg="8">
  56. <el-form-item label="分销金额:" label-width="90px">
  57. <el-input v-model="screenForm.amount1" size="small" @change="getListByScreen" clearable ></el-input>
  58. <span>至</span>
  59. <el-input v-model="screenForm.amount2" size="small" @change="getListByScreen" clearable ></el-input>
  60. </el-form-item>
  61. </el-col>
  62. </el-row>
  63. </div>
  64. </el-form>
  65. </el-col>
  66. <el-col :xs="24" :sm="2" :lg="3" style="opacity: 0;">.</el-col>
  67. </el-row>
  68. </div>
  69. <div class="mymain-container">
  70. <div class="btn-group clearfix">
  71. <div class="fl">
  72. <el-button v-if="$restrict('add')" type="primary" icon="el-icon-plus" size="small" @click="addOrEdit('add')">添加商品</el-button>
  73. <el-button v-if="$restrict('batchLaunch')" size="small" @click="batchOperation('on')">批量上架</el-button>
  74. <el-button v-if="$restrict('batchRemova')" size="small" @click="batchOperation('off')">批量下架</el-button>
  75. <el-button v-if="$restrict('batchSet')" size="small" @click="batchOperation('module')">批量设置模块</el-button>
  76. <el-button v-if="$restrict('batchSetfreight')" size="small" @click="batchOperation('freight')">批量设置运费</el-button>
  77. </div>
  78. </div>
  79. <div class="table">
  80. <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe @selection-change="handleTableSelection">
  81. <el-table-column align="center" type="selection" width="55" fixed></el-table-column>
  82. <el-table-column align="center" label="商品图片" prop="imgUrl" width="85">
  83. <template slot-scope="scope">
  84. <el-image style="width: 60px; height: 60px; display: block;" :src="scope.row.imgUrl" :preview-src-list="[scope.row.imgUrl]" fit="cover"></el-image>
  85. </template>
  86. </el-table-column>
  87. <el-table-column align="center" label="商品名称" prop="goodsName" min-width="200">
  88. <template slot-scope="scope">
  89. <!-- {{ scope.row.goodsName }} -->
  90. <span style="margin-right: 10px">{{ scope.row.goodsName }}</span>
  91. <i class="el-icon-edit pointer" @click="editData('goodsName', scope.row)"></i>
  92. </template>
  93. </el-table-column>
  94. <el-table-column align="center" label="状态" class-name="status-col">
  95. <template slot-scope="scope">
  96. <div style="display: flex; flex-wrap: wrap; align-items: center; justify-content: center;">
  97. <el-tag size="small" :type="scope.row.status ? 'success':'danger'">{{ scope.row.status ? '上架':'下架' }}</el-tag>
  98. <el-tag size="small" v-if="scope.row.promotionGroup" style="margin-top: 4px;">团购商品</el-tag>
  99. </div>
  100. </template>
  101. </el-table-column>
  102. <el-table-column align="center" label="销售价格" prop="goodsPrice" min-width="110" sortable>
  103. <template slot-scope="scope">
  104. <!-- ¥{{ scope.row.goodsPrice }} -->
  105. <span style="margin-right: 10px">¥{{ scope.row.goodsPrice }}</span>
  106. <i class="el-icon-edit pointer" @click="editData('price', scope.row)"></i>
  107. </template>
  108. </el-table-column>
  109. <el-table-column align="center" label="分销金额" prop="shareAmount" min-width="110" sortable>
  110. <template slot-scope="scope">
  111. <!-- ¥{{ scope.row.shareAmount }} -->
  112. <span style="margin-right: 10px">¥{{ scope.row.shareAmount }}</span>
  113. <i class="el-icon-edit pointer" @click="editData('shareAmount', scope.row)"></i>
  114. </template>
  115. </el-table-column>
  116. <el-table-column align="center" label="佣金比例" prop="sharePercent" min-width="110" sortable>
  117. <template slot-scope="scope">
  118. <!-- ¥{{ scope.row.sharePercent }} -->
  119. <span style="margin-right: 10px">{{ scope.row.sharePercent }}%</span>
  120. <i class="el-icon-edit pointer" @click="editData('sharePercent', scope.row)"></i>
  121. </template>
  122. </el-table-column>
  123. <el-table-column align="center" label="内部分销金额" prop="innerShareAmount" min-width="130" sortable>
  124. <template slot-scope="scope">
  125. <!-- ¥{{ scope.row.sharePercent }} -->
  126. <span style="margin-right: 10px">¥{{ scope.row.innerShareAmount }}</span>
  127. <i class="el-icon-edit pointer" @click="editData('innerShareAmount', scope.row)"></i>
  128. </template>
  129. </el-table-column>
  130. <el-table-column align="center" label="内部佣金比列" prop="innerSharePercent" min-width="130" sortable>
  131. <template slot-scope="scope">
  132. <!-- ¥{{ scope.row.sharePercent }} -->
  133. <span style="margin-right: 10px">{{ scope.row.innerSharePercent }}%</span>
  134. <i class="el-icon-edit pointer" @click="editData('innerSharePercent', scope.row)"></i>
  135. </template>
  136. </el-table-column>
  137. <el-table-column align="center" label="商品库存" prop="stockNum" min-width="110" sortable>
  138. <template slot-scope="scope">
  139. <!-- {{ scope.row.stockNum }} -->
  140. <span style="margin-right: 10px">{{ scope.row.stockNum }}</span>
  141. <i class="el-icon-edit pointer" @click="editData('stockNum', scope.row)"></i>
  142. </template>
  143. </el-table-column>
  144. <el-table-column align="center" label="仓库库存" prop="allStockNum" min-width="110" sortable></el-table-column>
  145. <el-table-column align="center" label="销量" prop="soldNum" min-width="110" sortable></el-table-column>
  146. <el-table-column align="center" label="排序" prop="sortNum" min-width="110" sortable>
  147. <template slot-scope="scope">
  148. <!-- {{ scope.row.sortNum }} -->
  149. <span style="margin-right: 10px">{{ scope.row.sortNum }}</span>
  150. <i class="el-icon-edit pointer" @click="editData('sortNum', scope.row)"></i>
  151. </template>
  152. </el-table-column>
  153. <el-table-column align="center" label="商户" prop="companyName" min-width="120"></el-table-column>
  154. <el-table-column align="center" label="操作" width="280" fixed="right">
  155. <template slot-scope="scope">
  156. <!-- <template>
  157. <el-popconfirm v-if="scope.row.status" style="margin-right: 10px;" title="确定冻结吗?" @confirm="changeMemberStatus(scope.row.goodsId, 0)" >
  158. <el-button slot="reference" type="text">冻结</el-button>
  159. </el-popconfirm>
  160. <el-popconfirm v-else style="margin-right: 10px;" title="确定恢复吗?" @confirm="changeMemberStatus(scope.row.goodsId, 1)" >
  161. <el-button slot="reference" type="text">恢复</el-button>
  162. </el-popconfirm>
  163. </template> -->
  164. <el-button v-if="$restrict('edit')" type="primary" size="mini" @click="addOrEdit('edit', scope.row.goodsId)">编辑</el-button>
  165. <el-popconfirm v-if="$restrict('clone')" style="margin-left: 10px; margin-right: 10px" title="确定克隆吗?" @confirm="clone(scope.row.goodsId)" >
  166. <el-button slot="reference" type="primary" size="mini">克隆</el-button>
  167. </el-popconfirm>
  168. <el-button v-if="$restrict('copyLink')" type="primary" size="mini" class="tag-read" @click="copy(scope.row.goodsId)" :data-clipboard-text="scope.row.goodsId">复制链接</el-button>
  169. <el-popconfirm v-if="$restrict('del')" style="margin-left: 10px;" title="确定删除吗?" @confirm="delItem(scope.row.goodsId, scope.row.goodsSpecId)" >
  170. <el-button slot="reference" size="mini">删除</el-button>
  171. </el-popconfirm>
  172. </template>
  173. </el-table-column>
  174. </el-table>
  175. </div>
  176. <div class="pagination clearfix">
  177. <div class="fr">
  178. <el-pagination
  179. @size-change="handleSizeChange"
  180. @current-change="handleCurrentChange"
  181. :current-page="currentPage"
  182. :page-sizes="[10, 20, 50, 100]"
  183. :page-size="10"
  184. layout="total, sizes, prev, pager, next, jumper"
  185. :total="listTotal">
  186. </el-pagination>
  187. </div>
  188. </div>
  189. </div>
  190. <!-- 编辑规格数据 -->
  191. <el-dialog title="编辑" :visible.sync="editSpecVisible" :show-close="false" width="60%" :close-on-click-modal="false">
  192. <el-table :data="editGoodsDetail.goodsSpecs" element-loading-text="Loading" border fit highlight-current-row stripe style="margin-bottom: 20px">
  193. <el-table-column align="center" label="规格名称" prop="name"></el-table-column>
  194. <el-table-column align="center" label="规格值" prop="specValue"></el-table-column>
  195. <el-table-column align="center" label="规格图片" prop="imgUrl">
  196. <template slot-scope="scope">
  197. <el-image style="width: 40px; height: 40px;" :src="scope.row.imgUrl" :preview-src-list="[scope.row.imgUrl]" fit="cover"></el-image>
  198. </template>
  199. </el-table-column>
  200. <el-table-column align="center" label="成本价格" prop="costPrice"></el-table-column>
  201. <el-table-column align="center" label="销售价格" prop="price" min-width="120">
  202. <template slot-scope="scope">
  203. <el-input v-model="scope.row.price" :disabled="editType != 'price'"></el-input>
  204. </template>
  205. </el-table-column>
  206. <el-table-column align="center" label="分销金额" prop="shareAmount" min-width="120">
  207. <template slot-scope="scope">
  208. <el-input v-model="scope.row.shareAmount" :disabled="editType != 'shareAmount'"></el-input>
  209. </template>
  210. </el-table-column>
  211. <el-table-column align="center" label="佣金比例(%)" prop="sharePercent" min-width="120">
  212. <template slot-scope="scope">
  213. <el-input v-model="scope.row.sharePercent" :disabled="editType != 'sharePercent'"></el-input>
  214. </template>
  215. </el-table-column>
  216. <el-table-column align="center" label="内部分销金额" prop="innerShareAmount" min-width="120">
  217. <template slot-scope="scope">
  218. <el-input v-model="scope.row.innerShareAmount" :disabled="editType !== 'innerShareAmount'"></el-input>
  219. </template>
  220. </el-table-column>
  221. <el-table-column align="center" label="内部佣金比例(%)" prop="innerSharePercent" min-width="130">
  222. <template slot-scope="scope">
  223. <el-input v-model="scope.row.innerSharePercent" :disabled="editType !== 'innerSharePercent'"></el-input>
  224. </template>
  225. </el-table-column>
  226. <el-table-column align="center" label="商品库存" prop="stockNum" min-width="120">
  227. <template slot-scope="scope">
  228. <el-input v-model="scope.row.stockNum" :disabled="editType != 'stockNum'"></el-input>
  229. </template>
  230. </el-table-column>
  231. <el-table-column align="center" label="仓库库存" prop="goodsMaterialStock"></el-table-column>
  232. <el-table-column align="center" label="物料编号" prop="goodsCode" min-width="120">
  233. <template slot-scope="scope">
  234. <el-input v-model="scope.row.goodsCode"></el-input>
  235. </template>
  236. </el-table-column>
  237. </el-table>
  238. <div slot="footer" class="dialog-footer">
  239. <el-button @click="cancelEditSpecForm">取 消</el-button>
  240. <el-button type="primary" @click="submitEditSpecForm">确 定</el-button>
  241. </div>
  242. </el-dialog>
  243. <!-- 批量设置模块 -->
  244. <el-dialog :title="'设置模块 (已选择' + tableSelection.length + '件商品)'" :visible.sync="setModuleVisible" :show-close="false" width="30%" :close-on-click-modal="false">
  245. <el-form ref="setModuleForm" :model="setModuleForm" :rules="setModuleFormRules" label-position="left" label-width="80px">
  246. <el-form-item label="说明模块" prop="module">
  247. <el-select v-model="setModuleForm.module" placeholder="请选择说明模块" style="width: 250px;">
  248. <el-option v-for="item in moduleList" :key="item.commonTemplateId" :label="item.name" :value="item.commonTemplateId">
  249. </el-option>
  250. </el-select>
  251. </el-form-item>
  252. </el-form>
  253. <div slot="footer" class="dialog-footer">
  254. <el-button @click="cancelSetModuleForm">取 消</el-button>
  255. <el-button type="primary" @click="submitSetModuleForm">确 定</el-button>
  256. </div>
  257. </el-dialog>
  258. <!-- 批量设置运费 -->
  259. <el-dialog :title="'设置运费 (已选择' + tableSelection.length + '件商品)'" :visible.sync="setFreightVisible" :show-close="false" width="30%" :close-on-click-modal="false">
  260. <el-form ref="setFreightForm" :model="setFreightForm" :rules="setFreightFormRules" label-position="left" label-width="80px">
  261. <el-form-item label="运费模版" prop="freight">
  262. <el-select v-model="setFreightForm.freight" placeholder="请选择运费模版" style="width: 250px;">
  263. <el-option v-for="item in freightList" :key="item.freightTemplateId" :label="item.name" :value="item.freightTemplateId">
  264. </el-option>
  265. </el-select>
  266. </el-form-item>
  267. </el-form>
  268. <div slot="footer" class="dialog-footer">
  269. <el-button @click="cancelSetFreightForm">取 消</el-button>
  270. <el-button type="primary" @click="submitSetFreightForm">确 定</el-button>
  271. </div>
  272. </el-dialog>
  273. </div>
  274. </template>
  275. <script>
  276. import { getGoodsList, deleteGoods, getClassifyList, getGoodsStateCount, cloneGoods, editGoods, goodsPutOn, goodsPutOff, checkSeckill, getGoodsDetail, getModuleList, setCommomModule, setFreight, getFreightList } from '@/api/goods'
  277. import Clipboard from 'clipboard'
  278. import { EventBus } from '@/utils/eventBus'
  279. export default {
  280. data() {
  281. return {
  282. dataList: null, // 列表数据
  283. listLoading: true, // 列表加载loading
  284. currentPage: 1, // 当前页码
  285. pageSize: 10, // 每页数量
  286. listTotal: 0, // 列表总数
  287. screenForm: {
  288. type: '',
  289. keyword: '',
  290. classify: '',
  291. status: '',
  292. price1: '',
  293. price2: '',
  294. amount1: '',
  295. amount2: '',
  296. },
  297. select_status: [ // 筛选字段 - 状态
  298. { label: '上架', value: true },
  299. { label: '下架', value: false }
  300. ],
  301. classifyList: [],
  302. goodsStateCount: {
  303. total: 0,
  304. csz: 0,
  305. ysq: 0,
  306. ckz: 0,
  307. hdz: 0,
  308. },
  309. tableSelection: [],
  310. editSpecVisible: false,
  311. editGoodsDetail: {},
  312. editType: '',
  313. setModuleVisible: false,
  314. moduleList: [],
  315. setModuleForm: {
  316. module: '',
  317. },
  318. setModuleFormRules: {
  319. module: [
  320. { required: true, message: '请选择说明模块', trigger: 'change' }
  321. ],
  322. },
  323. setFreightVisible: false,
  324. freightList: [],
  325. setFreightForm: {
  326. freight: '',
  327. },
  328. setFreightFormRules: {
  329. freight: [
  330. { required: true, message: '请选择运费模块', trigger: 'change' }
  331. ],
  332. },
  333. }
  334. },
  335. created() {
  336. this.getList();
  337. this.getClassifyList();
  338. EventBus.$on("updateGoodsListPage",()=>{
  339. this.getList();
  340. })
  341. },
  342. methods: {
  343. getClassifyList() {
  344. let params = {
  345. name: '',
  346. status: true
  347. };
  348. getClassifyList(params).then(res => {
  349. res.data.unshift({
  350. name: '全部',
  351. categoryId: '',
  352. children: null,
  353. });
  354. this.classifyList = res.data;
  355. })
  356. },
  357. getList() {
  358. this.listLoading = true;
  359. let categoryId = '';
  360. if(this.screenForm.classify) {
  361. categoryId = this.screenForm.classify[1];
  362. }
  363. let params = {
  364. flag: this.screenForm.type,
  365. keyword: this.screenForm.keyword,
  366. categoryId: categoryId,
  367. status: this.screenForm.status,
  368. startPrice: this.screenForm.price1,
  369. endPrice: this.screenForm.price2,
  370. startShare: this.screenForm.amount1,
  371. endShare: this.screenForm.amount2,
  372. pageNum: this.currentPage,
  373. pageSize: this.pageSize
  374. };
  375. getGoodsList(params).then(res => {
  376. console.log('-----------',res.data.records)
  377. this.dataList = res.data.records;
  378. this.listTotal = res.data.total;
  379. this.listLoading = false;
  380. })
  381. getGoodsStateCount({}).then(res => {
  382. this.goodsStateCount = res.data;
  383. })
  384. },
  385. // 更改每页数量
  386. handleSizeChange(val) {
  387. this.pageSize = val;
  388. this.currentPage = 1;
  389. this.getList();
  390. },
  391. // 更改当前页
  392. handleCurrentChange(val) {
  393. this.currentPage = val;
  394. this.getList();
  395. },
  396. // 筛选后重新获取列表
  397. getListByScreen() {
  398. this.currentPage = 1;
  399. this.getList();
  400. },
  401. // 切换类型
  402. changeType(type) {
  403. this.screenForm.type = type;
  404. this.getListByScreen();
  405. },
  406. // 删除商品
  407. delItem(goodsId, goodsSpecId) {
  408. deleteGoods({
  409. goodsId,
  410. goodsSpecId
  411. }).then(res => {
  412. this.getList();
  413. this.$successMsg();
  414. })
  415. },
  416. // 添加商品
  417. addOrEdit(type, id) {
  418. if(type == 'add') {
  419. this.$router.push({
  420. name: 'goods_add',
  421. query: {}
  422. })
  423. }else {
  424. this.$router.push({
  425. name: 'goods_add',
  426. query: {
  427. id
  428. }
  429. })
  430. }
  431. },
  432. // 克隆
  433. clone(id) {
  434. cloneGoods({
  435. goodsId: id
  436. }).then(res => {
  437. this.getList();
  438. })
  439. },
  440. copy() {
  441. const clipboard = new Clipboard('.tag-read');
  442. // clipboard.on('success', e => {
  443. // this.$successMsg('复制成功');
  444. // })
  445. clipboard.on('error', e =>{
  446. console.log('该浏览器不支持复制');
  447. return false;
  448. })
  449. this.$successMsg('复制成功');
  450. },
  451. // 编辑数据
  452. async editData(type, item) {
  453. const typeMap = {
  454. goodsName: '商品名称',
  455. price: '销售价格',
  456. shareAmount: '分销金额',
  457. sharePercent: '佣金比例',
  458. innerShareAmount: '内部分销金额',
  459. innerSharePercent: '内部佣金比例',
  460. stockNum: '商品库存',
  461. sortNum: '排序'
  462. }
  463. await getGoodsDetail({goodsId: item.goodsId}).then(res => {
  464. this.editGoodsDetail = res.data;
  465. })
  466. if(['sortNum', 'goodsName'].includes(type)) {
  467. let promptObj = {};
  468. if(['sortNum'].includes(type)) {
  469. promptObj = {
  470. inputType: 'number',
  471. inputValidator: function(value) {
  472. if(!value && value !== 0) return '请输入'+typeMap[type]
  473. if(value*1 < 0) return typeMap[type]+'不能小于0'
  474. },
  475. }
  476. }else {
  477. promptObj = {
  478. inputValidator: function(value) {
  479. if(!value) return '请输入'+typeMap[type]
  480. },
  481. }
  482. }
  483. this.$prompt('请输入'+typeMap[type], '编辑', {
  484. confirmButtonText: '确定',
  485. cancelButtonText: '取消',
  486. inputValue: this.editGoodsDetail[type],
  487. ...promptObj
  488. }).then(({ value }) => {
  489. let params = this.editGoodsDetail;
  490. params[type] = value;
  491. editGoods(params).then(res => {
  492. this.$successMsg('编辑成功');
  493. this.getList();
  494. })
  495. }).catch(() => {});
  496. }
  497. else {
  498. if(type == 'shareAmount' && item.sharePercent != 0) {
  499. return this.$errorMsg('佣金比例不为0的时候无法修改分销金额');
  500. }
  501. if(type === 'innerShareAmount' && item.innerSharePercent !== 0) {
  502. return this.$errorMsg('内部佣金比例不为0的时候无法修改内部分销金额');
  503. }
  504. this.editType = type;
  505. this.editSpecVisible = true;
  506. }
  507. },
  508. // 取消 编辑规格数据
  509. cancelEditSpecForm(){
  510. this.editSpecVisible = false;
  511. },
  512. // 提交 编辑规格数据
  513. submitEditSpecForm(){
  514. let specList = this.editGoodsDetail.goodsSpecs;
  515. for(let i=0; i<specList.length; i++) {
  516. if(specList[i].shareAmount / specList[i].price > 0.4) {
  517. this.formLoading = false;
  518. this.$errorMsg('单个规格的分销金额不能超过销售价的40%');
  519. return;
  520. }
  521. if(Number(specList[i].sharePercent) < 0 || Number(specList[i].sharePercent) > 40) {
  522. this.formLoading = false;
  523. this.$errorMsg('单个规格的佣金比例范围在0-40');
  524. return;
  525. }
  526. if(specList[i].innerShareAmount / specList[i].price > 0.4) {
  527. this.formLoading = false;
  528. this.$errorMsg('单个规格的内部分销金额不能超过销售价的40%');
  529. return;
  530. }
  531. if(Number(specList[i].innerSharePercent) < 0 || Number(specList[i].innerSharePercent) > 40) {
  532. this.formLoading = false;
  533. this.$errorMsg('单个规格的内部佣金比例范围在0-40');
  534. return;
  535. }
  536. }
  537. let allPrice = [];
  538. specList.forEach(item => {
  539. allPrice.push(item.price);
  540. })
  541. this.editGoodsDetail.goodsPrice = Math.min(...allPrice);
  542. let params = this.editGoodsDetail;
  543. editGoods(params).then(res => {
  544. this.editSpecVisible = false;
  545. this.$successMsg('编辑成功');
  546. this.getList();
  547. })
  548. },
  549. // 表格选择列
  550. handleTableSelection(val) {
  551. this.tableSelection = val;
  552. },
  553. // 批量操作
  554. batchOperation(type) {
  555. if(this.tableSelection.length < 1) {
  556. return this.$errorMsg('至少选择一个商品');
  557. }
  558. const typeMap = {
  559. on: '上架',
  560. off: '下架',
  561. module: '设置模块',
  562. freight: '设置运费'
  563. };
  564. // 批量上架/批量下架
  565. if(['on', 'off'].includes(type)) {
  566. this.$confirm('您确定要批量'+typeMap[type]+'选中商品吗?', '提示', {
  567. confirmButtonText: '确定',
  568. cancelButtonText: '取消',
  569. type: 'warning'
  570. }).then(() => {
  571. let goodsIds = [];
  572. this.tableSelection.forEach(item => {
  573. goodsIds.push(item.goodsId);
  574. });
  575. // 批量上架
  576. if(type == 'on') {
  577. goodsPutOn(goodsIds).then(res => {
  578. this.$successMsg();
  579. this.getList();
  580. })
  581. }
  582. // 批量下架
  583. else if(type == 'off') {
  584. checkSeckill(goodsIds).then(res => {
  585. if(res.data && res.data.length > 0) {
  586. let goodsNames = [];
  587. res.data.forEach(item => {
  588. let index = this.$findElem(this.tableSelection, 'goodsId', item);
  589. goodsNames.push('【' + this.tableSelection[index].goodsName + '】');
  590. })
  591. this.$confirm('你所选中的商品'+goodsNames.join('、')+'正在参与秒杀活动,是否确定下架?', '提示', {
  592. confirmButtonText: '确定',
  593. cancelButtonText: '取消',
  594. type: 'warning'
  595. }).then(() => {
  596. goodsPutOff(goodsIds).then(res => {
  597. this.$successMsg();
  598. this.getList();
  599. })
  600. }).catch(() => {});
  601. }else {
  602. goodsPutOff(goodsIds).then(res => {
  603. this.$successMsg();
  604. this.getList();
  605. })
  606. }
  607. })
  608. }
  609. }).catch(() => {});
  610. }
  611. // 批量设置模块
  612. else if(type == 'module') {
  613. this.getModuleList();
  614. this.setModuleVisible = true;
  615. }
  616. // 批量设置运费
  617. else if(type == 'freight') {
  618. this.getFreightList();
  619. this.setFreightVisible = true;
  620. }
  621. },
  622. // 获取模块列表
  623. getModuleList() {
  624. getModuleList({
  625. pageNum: 1,
  626. pageSize: 1000
  627. }).then(res => {
  628. this.moduleList = res.data.records;
  629. })
  630. },
  631. // 取消 设置模块
  632. cancelSetModuleForm(){
  633. this.setModuleVisible = false;
  634. this.$refs.setModuleForm.resetFields();
  635. },
  636. // 提交 设置模块
  637. submitSetModuleForm() {
  638. let goodsIds = [];
  639. this.tableSelection.forEach(item => {
  640. goodsIds.push(item.goodsId);
  641. });
  642. setCommomModule({
  643. goodsIdList: goodsIds,
  644. templateId: this.setModuleForm.module
  645. }).then(res => {
  646. this.cancelSetModuleForm();
  647. this.$successMsg();
  648. this.getList();
  649. })
  650. },
  651. // 获取运费模版列表
  652. getFreightList() {
  653. getFreightList({
  654. pageNum: 1,
  655. pageSize: 1000
  656. }).then(res => {
  657. this.freightList = res.data.records;
  658. })
  659. },
  660. // 取消 设置运费
  661. cancelSetFreightForm(){
  662. this.setFreightVisible = false;
  663. this.$refs.setFreightForm.resetFields();
  664. },
  665. // 提交 设置运费
  666. submitSetFreightForm() {
  667. let goodsIds = [];
  668. this.tableSelection.forEach(item => {
  669. goodsIds.push(item.goodsId);
  670. });
  671. setFreight({
  672. goodsIdList: goodsIds,
  673. freightTemplateId: this.setFreightForm.freight
  674. }).then(res => {
  675. this.cancelSetFreightForm();
  676. this.$successMsg();
  677. this.getList();
  678. })
  679. }
  680. }
  681. }
  682. </script>
  683. <style scoped lang="scss">
  684. .tab-container {
  685. .tab-list {
  686. .item {
  687. float: left;
  688. font-size: 14px;
  689. margin-right: 20px;
  690. cursor: pointer;
  691. line-height: 32px;
  692. &.current {
  693. color: #409EFF;
  694. }
  695. }
  696. }
  697. }
  698. .screen2-container {
  699. .search {
  700. margin-top: 30px;
  701. }
  702. .screen {
  703. margin-top: 20px;
  704. .el-input {
  705. width: 40%;
  706. }
  707. span {
  708. width: 20%;
  709. display: inline-block;
  710. text-align: center;
  711. color: #666666;
  712. }
  713. }
  714. }
  715. .pointer {
  716. cursor: pointer;
  717. color: #409EFF;
  718. }
  719. </style>
  720. <style lang="scss">
  721. .screen2-container {
  722. .el-form-item__label {
  723. line-height: 32px;
  724. }
  725. .el-form-item__content {
  726. line-height: 32px;
  727. }
  728. }
  729. .el-image-viewer__wrapper .el-icon-circle-close {
  730. color: #ffffff !important;
  731. font-size: 60px;
  732. }
  733. </style>