index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="分类" prop="cateId">
  5. <el-select v-model="queryParams.cateId" placeholder="请选择分类" clearable size="small" >
  6. <el-option
  7. v-for="item in cateOptions"
  8. :key="item.dictValue"
  9. :label="item.dictLabel"
  10. :value="item.dictValue"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="套餐名称" prop="title">
  15. <el-input
  16. v-model="queryParams.title"
  17. placeholder="请输入套餐名称"
  18. clearable
  19. size="small"
  20. @keyup.enter.native="handleQuery"
  21. />
  22. </el-form-item>
  23. <el-form-item label="状态" prop="status">
  24. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small" >
  25. <el-option
  26. v-for="item in statusOptions"
  27. :key="item.dictValue"
  28. :label="item.dictLabel"
  29. :value="item.dictValue"
  30. />
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item>
  34. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  35. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  36. </el-form-item>
  37. </el-form>
  38. <el-row :gutter="10" class="mb8">
  39. <el-col :span="1.5">
  40. <el-button
  41. type="primary"
  42. icon="el-icon-plus"
  43. size="mini"
  44. @click="handleAdd"
  45. v-hasPermi="['store:storeProductPackage:add']"
  46. >新增</el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="success"
  51. icon="el-icon-edit"
  52. size="mini"
  53. :disabled="multiple"
  54. @click="handleUpdateMore"
  55. v-hasPermi="['store:storeProductPackage:edit']"
  56. >修改</el-button>
  57. </el-col>
  58. <el-col :span="1.5">
  59. <el-button
  60. type="danger"
  61. icon="el-icon-delete"
  62. size="mini"
  63. :disabled="multiple"
  64. @click="handleDelete"
  65. v-hasPermi="['store:storeProductPackage:remove']"
  66. >删除</el-button>
  67. </el-col>
  68. <el-col :span="1.5">
  69. <el-button
  70. type="warning"
  71. icon="el-icon-download"
  72. size="mini"
  73. @click="handleExport"
  74. v-hasPermi="['store:storeProductPackage:export']"
  75. >导出</el-button>
  76. </el-col>
  77. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  78. </el-row>
  79. <el-table height="500" border v-loading="loading" :data="storeProductPackageList" @selection-change="handleSelectionChange">
  80. <el-table-column type="selection" width="55" align="center" />
  81. <el-table-column label="ID" align="center" prop="packageId" />
  82. <el-table-column label="封面" align="center" width="120">
  83. <template slot-scope="scope">
  84. <el-popover
  85. placement="right"
  86. title=""
  87. trigger="hover">
  88. <img slot="reference" :src="scope.row.imgUrl" width="100">
  89. <img :src="scope.row.imgUrl" style="max-width: 150px;">
  90. </el-popover>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="所属分类" align="center" prop="cateId" width="150px" >
  94. <template slot-scope="scope">
  95. <el-tag prop="cateId" v-for="(item, index) in cateOptions" v-if="scope.row.cateId==item.dictValue">{{item.dictLabel}}</el-tag>
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="标题" align="center" prop="title" show-overflow-tooltip />
  99. <el-table-column label="描述" align="center" prop="descs" show-overflow-tooltip />
  100. <el-table-column label="原价" align="center" >
  101. <template slot-scope="scope">
  102. <div v-if="scope.row.money!=null" >
  103. {{scope.row.money.toFixed(2)}}
  104. </div>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="套餐价格" align="center" >
  108. <template slot-scope="scope">
  109. <div v-if="scope.row.payMoney!=null" >
  110. {{scope.row.payMoney.toFixed(2)}}
  111. </div>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="支付类型" align="center" prop="payType" width="150px" >
  115. <template slot-scope="scope">
  116. <el-tag prop="payType" v-for="(item, index) in storePayTypeOptions" v-if="scope.row.payType==item.dictValue">{{item.dictLabel}}</el-tag>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="限购次数" align="center" prop="limitCount" />
  120. <el-table-column label="排序" align="center" prop="sort" />
  121. <!-- <el-table-column label="所属部门" align="center" prop="deptName" /> -->
  122. <el-table-column label="状态" align="center" prop="status" >
  123. <template slot-scope="scope">
  124. <el-tag prop="status" v-for="(item, index) in statusOptions" v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="操作" align="center" fixed="right" width="120px" class-name="small-padding fixed-width">
  128. <template slot-scope="scope">
  129. <el-button
  130. size="mini"
  131. type="text"
  132. icon="el-icon-edit"
  133. @click="handleUpdate(scope.row)"
  134. v-hasPermi="['store:storeProductPackage:edit']"
  135. >修改</el-button>
  136. <el-button
  137. size="mini"
  138. type="text"
  139. icon="el-icon-delete"
  140. @click="handleDelete(scope.row)"
  141. v-hasPermi="['store:storeProductPackage:remove']"
  142. >删除</el-button>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. <pagination
  147. v-show="total>0"
  148. :total="total"
  149. :page.sync="queryParams.pageNum"
  150. :limit.sync="queryParams.pageSize"
  151. @pagination="getList"
  152. />
  153. <el-dialog :title="title" :visible.sync="open1" width="580px" append-to-body>
  154. <el-form ref="form1" :model="form1" :rules="rules" label-width="80px">
  155. <el-form-item label="状态" prop="status">
  156. <el-radio-group v-model="form1.status">
  157. <el-radio :label="item.dictValue" v-for="item in statusOptions" >{{item.dictLabel}}</el-radio>
  158. </el-radio-group>
  159. </el-form-item>
  160. </el-form>
  161. <div slot="footer" class="dialog-footer">
  162. <el-button type="primary" @click="submitForm1">确 定</el-button>
  163. <el-button @click="cancel1">取 消</el-button>
  164. </div>
  165. </el-dialog>
  166. <!-- 添加或修改商品组合套餐对话框 -->
  167. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  168. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  169. <el-form-item label="套餐封面" prop="imgUrl">
  170. <Material v-model="imageArr" type="image" :num="1" :width="150" :height="150" />
  171. </el-form-item>
  172. <el-form-item label="套餐组图" prop="images">
  173. <Material v-model="photoArr" type="image" :num="10" :width="150" :height="150" />
  174. </el-form-item>
  175. <el-form-item label="套餐标题" prop="title">
  176. <el-input v-model="form.title" placeholder="请输入套餐标题" />
  177. </el-form-item>
  178. <el-form-item label="所属分类" props="cateId">
  179. <el-select style="width: 200px" v-model="form.cateId" placeholder="请选择分类" clearable size="small" >
  180. <el-option
  181. v-for="item in cateOptions"
  182. :key="item.dictValue"
  183. :label="item.dictLabel"
  184. :value="item.dictValue"
  185. />
  186. </el-select>
  187. </el-form-item>
  188. <el-form-item label="套餐描述" prop="descs">
  189. <el-input type="textarea" v-model="form.descs" placeholder="请输入描述" />
  190. </el-form-item>
  191. <el-form-item label="套餐详情" prop="content">
  192. <Editor ref="myeditor" :min-height="192" @on-text-change="updateText" />
  193. </el-form-item>
  194. <el-form-item label="套餐商品" prop="productList" >
  195. <el-row>
  196. <el-col>
  197. <el-button plain type="primary" icon="el-icon-plus" @click="handleAddProduct">添加商品</el-button>
  198. </el-col>
  199. </el-row>
  200. <el-table border width="100%" style="margin-top:5px;" :data="products">
  201. <el-table-column label="商品编号" align="center" prop="barCode" />
  202. <el-table-column label="商品图片" align="center" width="100">
  203. <template slot-scope="scope">
  204. <el-popover
  205. placement="right"
  206. title=""
  207. trigger="hover"
  208. >
  209. <img slot="reference" :src="scope.row.image" width="50">
  210. <img :src="scope.row.image" style="max-width: 50px;">
  211. </el-popover>
  212. </template>
  213. </el-table-column>
  214. <el-table-column label="商品名称" show-overflow-tooltip align="center" prop="productName" />
  215. <el-table-column label="商品规格" align="center" prop="sku" />
  216. <el-table-column label="仓库代码" align="center" prop="prodWareHouseCode" />
  217. <!-- <el-table-column label="库存" align="center" prop="stock" /> -->
  218. <el-table-column label="售价" align="center" prop="price" >
  219. <template slot-scope="scope">
  220. <div v-if="scope.row.price!=null">
  221. {{scope.row.price.toFixed(2)}}
  222. </div>
  223. </template>
  224. </el-table-column>
  225. <!-- <el-table-column label="代理价" align="center" prop="agentPrice" /> -->
  226. <el-table-column label="数量" align="center" prop="count" width="200px" >
  227. <template slot-scope="scope">
  228. <div>
  229. <el-input-number v-model="scope.row.count" @change="handleProductCountChange(scope.row)" size="mini" :min="1" ></el-input-number>
  230. </div>
  231. </template>
  232. </el-table-column>
  233. <el-table-column label="小计" align="center" prop="money" >
  234. <template slot-scope="scope">
  235. <div v-if="scope.row.money!=null">
  236. {{scope.row.money.toFixed(2)}}
  237. </div>
  238. </template>
  239. </el-table-column>
  240. <el-table-column label="操作" align="center" width="100px" >
  241. <template slot-scope="scope">
  242. <el-button
  243. size="mini"
  244. type="text"
  245. icon="el-icon-delete"
  246. @click="handleProductDelete(scope.row)"
  247. >删除</el-button>
  248. </template>
  249. </el-table-column>
  250. </el-table>
  251. <el-row >
  252. <el-col >
  253. <span style="margin-left:10px;" v-if="totalMoney!=null">商品总价:{{totalMoney}}</span>
  254. </el-col>
  255. </el-row>
  256. </el-form-item>
  257. <el-form-item label="原价" prop="money">
  258. <el-input-number v-model="form.money" :precision="2" :min="0.00" placeholder="请输入原价" />
  259. </el-form-item>
  260. <el-form-item label="套餐价格" prop="payMoney">
  261. <el-input-number v-model="form.payMoney" :precision="2" :min="0.00" placeholder="请输入套餐价格" />
  262. </el-form-item>
  263. <el-form-item label="支付类型" props="payType">
  264. <el-radio-group v-model="form.payType">
  265. <el-radio v-if="item.dictValue!=3" :label="item.dictValue" v-for="item in storePayTypeOptions" >{{item.dictLabel}}</el-radio>
  266. </el-radio-group>
  267. </el-form-item>
  268. <el-form-item label="限购次数" prop="limitCount">
  269. <el-input-number v-model="form.limitCount" :min="0" :step="1" placeholder="请输入限购次数" />
  270. </el-form-item>
  271. <el-form-item label="排序" prop="sort">
  272. <el-input-number v-model="form.sort" :min="1" />
  273. </el-form-item>
  274. <el-form-item label="状态" prop="status">
  275. <el-radio-group v-model="form.status">
  276. <el-radio :label="item.dictValue" v-for="item in statusOptions" >{{item.dictLabel}}</el-radio>
  277. </el-radio-group>
  278. </el-form-item>
  279. <el-form-item label="分期赠送优惠券" prop="icgEnable" v-hasPermi="['store:storeProductPackage:edit:coupon']">
  280. <el-radio-group v-model="icgEnableModel">
  281. <el-radio :label="item.dictValue" v-for="item in icgEnableOptions" >{{item.dictLabel}}</el-radio>
  282. </el-radio-group>
  283. </el-form-item>
  284. <el-form-item label="优惠券" prop="icgCouponsId" v-if="form.icgEnable==1" v-hasPermi="['store:storeProductPackage:edit:coupon']">
  285. <el-select v-model="form.icgCouponsId" filterable multiple placeholder="请选择">
  286. <el-option
  287. v-for="item in icgCouponsOptions"
  288. :key="item.couponId"
  289. :label="item.couponName"
  290. :value="item.couponId">
  291. <span style="float: left">{{ item.couponName }}</span>
  292. <span style="float: right; color: #8492a6; font-size: 13px">id:{{item.id}},已领取{{ item.remainCount }}</span>
  293. </el-option>
  294. </el-select>
  295. </el-form-item>
  296. <el-form-item label="发放月数" prop="icgMonth" v-if="form.icgEnable==1" v-hasPermi="['store:storeProductPackage:edit:coupon']">
  297. <el-input-number v-model="form.icgMonth" placeholder="月数"/>
  298. </el-form-item>
  299. <el-form-item label="优惠券跳转URL" prop="icgUrl" v-if="form.icgEnable==1" v-hasPermi="['store:storeProductPackage:edit:coupon']">
  300. <el-input v-model="form.icgUrl" placeholder="优惠券跳转URL(没有则无跳转)"/>
  301. </el-form-item>
  302. <el-form-item label="优惠券备注信息" prop="icgMark" v-if="form.icgEnable==1" v-hasPermi="['store:storeProductPackage:edit:coupon']">
  303. <el-input v-model="form.icgMark" placeholder="优惠券备注信息"/>
  304. </el-form-item>
  305. </el-form>
  306. <div slot="footer" class="dialog-footer">
  307. <el-button type="primary" @click="submitForm">确 定</el-button>
  308. <el-button @click="cancel">取 消</el-button>
  309. </div>
  310. </el-dialog>
  311. <el-dialog :title="product.title" v-if="product.open" :visible.sync="product.open" width="1000px" append-to-body>
  312. <product-attr-value-select ref="product" @selectProduct="selectProduct" />
  313. </el-dialog>
  314. </div>
  315. </template>
  316. <script>
  317. import { listStoreProductPackage, getStoreProductPackage, delStoreProductPackage, addStoreProductPackage, updateStoreProductPackage, exportStoreProductPackage,modifyStoreProductPackages } from "@/api/store/storeProductPackage";
  318. import Editor from '@/components/Editor/wang';
  319. import productAttrValueSelect from "../components/productAttrValueSelect";
  320. import Material from '@/components/Material'
  321. import singleImg from '@/components/Material/single'
  322. import {listAllAvailable} from "../../../api/store/storeCouponIssue";
  323. export default {
  324. name: "StoreProductPackage",
  325. components: {
  326. Editor,
  327. productAttrValueSelect,
  328. Material,
  329. singleImg,
  330. },
  331. watch: {
  332. imageArr: function(val) {
  333. this.form.imgUrl = val.join(',')
  334. },
  335. photoArr: function(val) {
  336. this.form.images = val.join(',')
  337. }
  338. },
  339. data() {
  340. return {
  341. icgCouponsOptions:[],
  342. statusOptions:[],
  343. cateOptions:[],
  344. photoArr:[],
  345. imageArr:[],
  346. storePayTypeOptions:[],
  347. icgEnableOptions: [],
  348. totalMoney:0.00,
  349. products:[],
  350. product:{
  351. open:false,
  352. title:"商品选择"
  353. },
  354. // 遮罩层
  355. loading: true,
  356. // 选中数组
  357. ids: [],
  358. // 非单个禁用
  359. single: true,
  360. // 非多个禁用
  361. multiple: true,
  362. // 显示搜索条件
  363. showSearch: true,
  364. // 总条数
  365. total: 0,
  366. // 商品组合套餐表格数据
  367. storeProductPackageList: [],
  368. // 弹出层标题
  369. title: "",
  370. // 是否显示弹出层
  371. open: false,
  372. // 是否显示批量修改弹出层
  373. open1: false,
  374. // 查询参数
  375. queryParams: {
  376. pageNum: 1,
  377. pageSize: 10,
  378. title: null,
  379. descs: null,
  380. content: null,
  381. imgUrl: null,
  382. productIds: null,
  383. productAttrValueIds: null,
  384. money: null,
  385. payMoney: null,
  386. companyId: null,
  387. companyUserId: null
  388. },
  389. // 表单参数
  390. form: {},
  391. // 表单参数
  392. form1: {},
  393. // 表单校验
  394. rules: {
  395. title: [
  396. { required: true, message: "标题不能为空" }
  397. ],
  398. descs: [
  399. { required: true, message: "描述不能为空" }
  400. ],
  401. content: [
  402. { required: true, message: "详情不能为空" }
  403. ],
  404. imgUrl: [
  405. { required: true, message: "封面不能为空" }
  406. ],
  407. images: [
  408. { required: true, message: "组图不能为空" }
  409. ],
  410. productList: [
  411. { required: true, message: "商品不能为空" }
  412. ],
  413. payMoney: [
  414. { required: true, message: "套餐价格不能为空" }
  415. ],
  416. payType: [
  417. { required: true, message: "支付类型不能为空" }
  418. ],
  419. limitCount: [
  420. { required: true, message: "限购次数不能为空" }
  421. ],
  422. }
  423. };
  424. },
  425. created() {
  426. this.getDicts("common_status").then((response) => {
  427. this.statusOptions = response.data;
  428. });
  429. this.getDicts("store_product_package_cate").then((response) => {
  430. this.cateOptions = response.data;
  431. });
  432. this.getDicts("store_pay_type").then((response) => {
  433. this.storePayTypeOptions = response.data;
  434. });
  435. this.getDicts('coupon_installment_switch').then(response=>{
  436. this.icgEnableOptions = response.data;
  437. })
  438. this.getList();
  439. this.loadStoreCouponList();
  440. },
  441. computed:{
  442. icgEnableModel: {
  443. get(){
  444. return this.form.icgEnable?.toString();
  445. },
  446. set(newVal){
  447. this.form.icgEnable = newVal;
  448. }
  449. }
  450. },
  451. methods: {
  452. loadStoreCouponList(){
  453. listAllAvailable().then(response=>{
  454. this.icgCouponsOptions=response.data;
  455. })
  456. },
  457. handleProductCountChange(row){
  458. row.money=row.count*row.price;
  459. this.$forceUpdate();
  460. this.compute();
  461. },
  462. handleProductDelete(row){
  463. this.products.splice(this.products.findIndex(item => item.id === row.id), 1)
  464. this.compute();
  465. },
  466. compute(){
  467. this.totalMoney=0;
  468. var that=this;
  469. this.products.forEach (function (value) {
  470. that.totalMoney += value.money;
  471. });
  472. that.totalMoney=that.totalMoney.toFixed(2);
  473. },
  474. selectProduct(row){
  475. console.log(row);
  476. for(var i=0;i<this.products.length;i++){
  477. if(this.products[i].id==row.id){
  478. return;
  479. }
  480. }
  481. row.count=1;
  482. row.money=row.count*row.price;
  483. let testProduct = [...this.products,row]
  484. if (!this.checkProductsWarehouseCode(testProduct)) {
  485. this.$message.error("商品仓库代码不一致,且不能为空");
  486. return;
  487. }
  488. this.products.push(row);
  489. this.compute();
  490. this.$message.success('添加成功!')
  491. },
  492. checkProductsWarehouseCode(products) {
  493. const warehouseCodeSet = new Set(products.map(row => row.prodWareHouseCode));
  494. // 2. 检查 Set 大小是否为 1
  495. if (warehouseCodeSet.size !== 1) {
  496. return false;
  497. }
  498. // 3. 获取 Set 中的唯一元素(因为 Set 大小为 1,所以可以直接获取)
  499. const [singleWarehouseCode] = warehouseCodeSet;
  500. // 4. 检查唯一元素是否为空
  501. if (singleWarehouseCode === null || singleWarehouseCode === undefined || singleWarehouseCode === '') {
  502. return false; // 元素为空
  503. }
  504. return true; // 所有条件都满足
  505. },
  506. handleAddProduct(){
  507. this.product.open=true;
  508. // setTimeout(() => {
  509. // this.$refs.product.getData(1);
  510. // }, 200);
  511. },
  512. handleAvatarSuccess(res, file) {
  513. if(res.code==200){
  514. this.form.imgUrl=res.url;
  515. }
  516. else{
  517. this.msgError(res.msg);
  518. }
  519. },
  520. beforeAvatarUpload(file) {
  521. const isLt1M = file.size / 1024 / 1024 < 1;
  522. if (!isLt1M) {
  523. this.$message.error('上传图片大小不能超过 1MB!');
  524. }
  525. return isLt1M;
  526. },
  527. updateText(text){
  528. this.form.content=text;
  529. },
  530. /** 查询商品组合套餐列表 */
  531. getList() {
  532. this.loading = true;
  533. listStoreProductPackage(this.queryParams).then(response => {
  534. this.storeProductPackageList = response.rows;
  535. this.total = response.total;
  536. this.loading = false;
  537. });
  538. },
  539. // 取消按钮
  540. cancel() {
  541. this.open = false;
  542. this.reset();
  543. },
  544. // 表单重置
  545. reset() {
  546. this.form = {
  547. packageId: null,
  548. title: null,
  549. descs: null,
  550. content: null,
  551. imgUrl: null,
  552. images: null,
  553. money: null,
  554. payMoney: null,
  555. companyId: null,
  556. companyUserId: null,
  557. payType:"1",
  558. limitCount:0,
  559. cateId:"0",
  560. status:"1",
  561. icgEnable: "0",
  562. productList:null,
  563. icgCouponsId: [],
  564. icgMonth: 0,
  565. icgUrl: null,
  566. icgMark: null,
  567. };
  568. this.products=[];
  569. this.photoArr=[];
  570. this.imageArr=[];
  571. this.resetForm("form");
  572. },
  573. /** 搜索按钮操作 */
  574. handleQuery() {
  575. this.queryParams.pageNum = 1;
  576. this.getList();
  577. },
  578. /** 重置按钮操作 */
  579. resetQuery() {
  580. this.resetForm("queryForm");
  581. this.handleQuery();
  582. },
  583. // 多选框选中数据
  584. handleSelectionChange(selection) {
  585. this.ids = selection.map(item => item.packageId)
  586. this.single = selection.length!==1
  587. this.multiple = !selection.length
  588. },
  589. /** 新增按钮操作 */
  590. handleAdd() {
  591. this.reset();
  592. this.open = true;
  593. this.title = "添加商品组合套餐";
  594. setTimeout(() => {
  595. this.$refs.myeditor.setText("");
  596. }, 200);
  597. },
  598. /** 修改按钮操作 */
  599. handleUpdate(row) {
  600. this.reset();
  601. const packageId = row.packageId || this.ids
  602. getStoreProductPackage(packageId).then(response => {
  603. this.form = response.data;
  604. this.open = true;
  605. this.title = "修改商品组合套餐";
  606. this.products=this.form.productList;
  607. for(var i=0;i<this.products.length;i++){
  608. this.products[i].money=this.products[i].count*this.products[i].price;
  609. }
  610. this.compute();
  611. setTimeout(() => {
  612. if(this.form.content==null){
  613. this.$refs.myeditor.setText("");
  614. }
  615. else{
  616. this.$refs.myeditor.setText(this.form.content);
  617. }
  618. }, 200);
  619. this.form.payType = response.data.payType.toString();
  620. this.form.status = response.data.status.toString();
  621. if(this.form.imgUrl!=null){
  622. this.imageArr=this.form.imgUrl.split(",");
  623. }
  624. if(this.form.images!=null){
  625. this.photoArr=this.form.images.split(",");
  626. }
  627. if(this.form.cateId!=null){
  628. this.form.cateId = response.data.cateId.toString();
  629. }
  630. this.$forceUpdate();
  631. });
  632. },
  633. /** 提交按钮 */
  634. submitForm() {
  635. this.form.productList=[];
  636. this.products.forEach((item) => {
  637. var data={id:item.id,count:item.count}
  638. this.form.productList.push(data)
  639. })
  640. // console.log(this.form)
  641. // return;
  642. this.$refs["form"].validate(valid => {
  643. if (valid) {
  644. if (!this.checkProductsWarehouseCode(this.products)) {
  645. this.$message.error("商品仓库代码不一致,且不能为空");
  646. return;
  647. }
  648. if (this.form.packageId != null) {
  649. updateStoreProductPackage(this.form).then(response => {
  650. if (response.code === 200) {
  651. this.msgSuccess("修改成功");
  652. this.open = false;
  653. this.getList();
  654. }
  655. });
  656. } else {
  657. addStoreProductPackage(this.form).then(response => {
  658. if (response.code === 200) {
  659. this.msgSuccess("新增成功");
  660. this.open = false;
  661. this.getList();
  662. }
  663. });
  664. }
  665. }
  666. });
  667. },
  668. /** 删除按钮操作 */
  669. handleDelete(row) {
  670. const packageIds = row.packageId || this.ids;
  671. this.$confirm('是否确认删除商品组合套餐编号为"' + packageIds + '"的数据项?', "警告", {
  672. confirmButtonText: "确定",
  673. cancelButtonText: "取消",
  674. type: "warning"
  675. }).then(function() {
  676. return delStoreProductPackage(packageIds);
  677. }).then(() => {
  678. this.getList();
  679. this.msgSuccess("删除成功");
  680. }).catch(function() {});
  681. },
  682. /** 导出按钮操作 */
  683. handleExport() {
  684. const queryParams = this.queryParams;
  685. this.$confirm('是否确认导出所有商品组合套餐数据项?', "警告", {
  686. confirmButtonText: "确定",
  687. cancelButtonText: "取消",
  688. type: "warning"
  689. }).then(function() {
  690. return exportStoreProductPackage(queryParams);
  691. }).then(response => {
  692. this.download(response.msg);
  693. }).catch(function() {});
  694. },
  695. handleUpdateMore(row){
  696. this.title = "批量修改套餐状态";
  697. const packageIds = row.packageId || this.ids;
  698. this.form1.packageIds=packageIds;
  699. this.open1 = true;
  700. },
  701. // 取消按钮
  702. cancel1() {
  703. this.open = false;
  704. this.reset();
  705. },
  706. // 表单重置
  707. reset1() {
  708. this.form1 = {
  709. status:"1",
  710. packageIds:[],
  711. };
  712. this.resetForm("form1");
  713. },
  714. /** 提交按钮 */
  715. submitForm1() {
  716. if(this.form1.status==null){
  717. this.msgError("请选择套餐状态");
  718. return;
  719. }
  720. this.$refs["form1"].validate(valid => {
  721. if (valid) {
  722. if (this.form1.packageIds != null) {
  723. modifyStoreProductPackages(this.form1).then(response => {
  724. if (response.code === 200) {
  725. this.msgSuccess("操作成功");
  726. this.open1 = false;
  727. this.getList();
  728. }
  729. });
  730. }
  731. }
  732. });
  733. },
  734. }
  735. };
  736. </script>
  737. <style scoped lang="scss">
  738. .items{
  739. margin: 5px 0px;
  740. display: flex;
  741. flex-direction: row;
  742. align-items: center;
  743. justify-content: flex-start;
  744. .pic{
  745. width:60px;
  746. height:60px;
  747. }
  748. .goods-content{
  749. margin-left: 10px;
  750. max-width: 200px;
  751. text-align: left;
  752. .goods-title{
  753. overflow:hidden;
  754. white-space: nowrap;
  755. text-overflow: ellipsis;
  756. -o-text-overflow:ellipsis;
  757. }
  758. }
  759. }
  760. </style>