index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  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="stock" /> -->
  217. <el-table-column label="售价" align="center" prop="price" >
  218. <template slot-scope="scope">
  219. <div v-if="scope.row.price!=null">
  220. {{scope.row.price.toFixed(2)}}
  221. </div>
  222. </template>
  223. </el-table-column>
  224. <!-- <el-table-column label="代理价" align="center" prop="agentPrice" /> -->
  225. <el-table-column label="数量" align="center" prop="count" width="200px" >
  226. <template slot-scope="scope">
  227. <div>
  228. <el-input-number v-model="scope.row.count" @change="handleProductCountChange(scope.row)" size="mini" :min="1" ></el-input-number>
  229. </div>
  230. </template>
  231. </el-table-column>
  232. <el-table-column label="小计" align="center" prop="money" >
  233. <template slot-scope="scope">
  234. <div v-if="scope.row.money!=null">
  235. {{scope.row.money.toFixed(2)}}
  236. </div>
  237. </template>
  238. </el-table-column>
  239. <el-table-column label="操作" align="center" width="100px" >
  240. <template slot-scope="scope">
  241. <el-button
  242. size="mini"
  243. type="text"
  244. icon="el-icon-delete"
  245. @click="handleProductDelete(scope.row)"
  246. >删除</el-button>
  247. </template>
  248. </el-table-column>
  249. </el-table>
  250. <el-row >
  251. <el-col >
  252. <span style="margin-left:10px;" v-if="totalMoney!=null">商品总价:{{totalMoney}}</span>
  253. </el-col>
  254. </el-row>
  255. </el-form-item>
  256. <el-form-item label="原价" prop="money">
  257. <el-input-number v-model="form.money" :precision="2" :min="0.00" placeholder="请输入原价" />
  258. </el-form-item>
  259. <el-form-item label="套餐价格" prop="payMoney">
  260. <el-input-number v-model="form.payMoney" :precision="2" :min="0.00" placeholder="请输入套餐价格" />
  261. </el-form-item>
  262. <el-form-item label="支付类型" props="payType">
  263. <el-radio-group v-model="form.payType">
  264. <el-radio v-if="item.dictValue!=3" :label="item.dictValue" v-for="item in storePayTypeOptions" >{{item.dictLabel}}</el-radio>
  265. </el-radio-group>
  266. </el-form-item>
  267. <el-form-item label="限购次数" prop="limitCount">
  268. <el-input-number v-model="form.limitCount" :min="0" :step="1" placeholder="请输入限购次数" />
  269. </el-form-item>
  270. <el-form-item label="排序" prop="sort">
  271. <el-input-number v-model="form.sort" :min="1" />
  272. </el-form-item>
  273. <el-form-item label="状态" prop="status">
  274. <el-radio-group v-model="form.status">
  275. <el-radio :label="item.dictValue" v-for="item in statusOptions" >{{item.dictLabel}}</el-radio>
  276. </el-radio-group>
  277. </el-form-item>
  278. <el-form-item label="分期赠送优惠券" prop="icgEnable" v-hasPermi="['store:storeProductPackage:edit:coupon']">
  279. <el-radio-group v-model="icgEnableModel">
  280. <el-radio :label="item.dictValue" v-for="item in icgEnableOptions" >{{item.dictLabel}}</el-radio>
  281. </el-radio-group>
  282. </el-form-item>
  283. <el-form-item label="优惠券" prop="icgCouponsId" v-if="form.icgEnable==1" v-hasPermi="['store:storeProductPackage:edit:coupon']">
  284. <el-select v-model="form.icgCouponsId" filterable multiple placeholder="请选择">
  285. <el-option
  286. v-for="item in icgCouponsOptions"
  287. :key="item.couponId"
  288. :label="item.couponName"
  289. :value="item.couponId">
  290. <span style="float: left">{{ item.couponName }}</span>
  291. <span style="float: right; color: #8492a6; font-size: 13px">id:{{item.id}},剩余{{ item.remainCount }}</span>
  292. </el-option>
  293. </el-select>
  294. </el-form-item>
  295. <el-form-item label="发放月数" prop="icgMonth" v-if="form.icgEnable==1" v-hasPermi="['store:storeProductPackage:edit:coupon']">
  296. <el-input-number v-model="form.icgMonth" placeholder="月数"/>
  297. </el-form-item>
  298. <el-form-item label="优惠券跳转URL" prop="icgUrl" v-if="form.icgEnable==1" v-hasPermi="['store:storeProductPackage:edit:coupon']">
  299. <el-input v-model="form.icgUrl" placeholder="优惠券跳转URL(没有则无跳转)"/>
  300. </el-form-item>
  301. <el-form-item label="优惠券备注信息" prop="icgMark" v-if="form.icgEnable==1" v-hasPermi="['store:storeProductPackage:edit:coupon']">
  302. <el-input v-model="form.icgMark" placeholder="优惠券备注信息"/>
  303. </el-form-item>
  304. </el-form>
  305. <div slot="footer" class="dialog-footer">
  306. <el-button type="primary" @click="submitForm">确 定</el-button>
  307. <el-button @click="cancel">取 消</el-button>
  308. </div>
  309. </el-dialog>
  310. <el-dialog :title="product.title" v-if="product.open" :visible.sync="product.open" width="1000px" append-to-body>
  311. <product-attr-value-select ref="product" @selectProduct="selectProduct" />
  312. </el-dialog>
  313. </div>
  314. </template>
  315. <script>
  316. import { listStoreProductPackage, getStoreProductPackage, delStoreProductPackage, addStoreProductPackage, updateStoreProductPackage, exportStoreProductPackage,modifyStoreProductPackages } from "@/api/store/storeProductPackage";
  317. import Editor from '@/components/Editor/wang';
  318. import productAttrValueSelect from "../components/productAttrValueSelect";
  319. import Material from '@/components/Material'
  320. import singleImg from '@/components/Material/single'
  321. import {listAllAvailable} from "../../../api/store/storeCouponIssue";
  322. export default {
  323. name: "StoreProductPackage",
  324. components: {
  325. Editor,
  326. productAttrValueSelect,
  327. Material,
  328. singleImg,
  329. },
  330. watch: {
  331. imageArr: function(val) {
  332. this.form.imgUrl = val.join(',')
  333. },
  334. photoArr: function(val) {
  335. this.form.images = val.join(',')
  336. }
  337. },
  338. data() {
  339. return {
  340. icgCouponsOptions:[],
  341. statusOptions:[],
  342. cateOptions:[],
  343. photoArr:[],
  344. imageArr:[],
  345. storePayTypeOptions:[],
  346. icgEnableOptions: [],
  347. totalMoney:0.00,
  348. products:[],
  349. product:{
  350. open:false,
  351. title:"商品选择"
  352. },
  353. // 遮罩层
  354. loading: true,
  355. // 选中数组
  356. ids: [],
  357. // 非单个禁用
  358. single: true,
  359. // 非多个禁用
  360. multiple: true,
  361. // 显示搜索条件
  362. showSearch: true,
  363. // 总条数
  364. total: 0,
  365. // 商品组合套餐表格数据
  366. storeProductPackageList: [],
  367. // 弹出层标题
  368. title: "",
  369. // 是否显示弹出层
  370. open: false,
  371. // 是否显示批量修改弹出层
  372. open1: false,
  373. // 查询参数
  374. queryParams: {
  375. pageNum: 1,
  376. pageSize: 10,
  377. title: null,
  378. descs: null,
  379. content: null,
  380. imgUrl: null,
  381. productIds: null,
  382. productAttrValueIds: null,
  383. money: null,
  384. payMoney: null,
  385. companyId: null,
  386. companyUserId: null
  387. },
  388. // 表单参数
  389. form: {},
  390. // 表单参数
  391. form1: {},
  392. // 表单校验
  393. rules: {
  394. title: [
  395. { required: true, message: "标题不能为空" }
  396. ],
  397. descs: [
  398. { required: true, message: "描述不能为空" }
  399. ],
  400. content: [
  401. { required: true, message: "详情不能为空" }
  402. ],
  403. imgUrl: [
  404. { required: true, message: "封面不能为空" }
  405. ],
  406. images: [
  407. { required: true, message: "组图不能为空" }
  408. ],
  409. productList: [
  410. { required: true, message: "商品不能为空" }
  411. ],
  412. payMoney: [
  413. { required: true, message: "套餐价格不能为空" }
  414. ],
  415. payType: [
  416. { required: true, message: "支付类型不能为空" }
  417. ],
  418. limitCount: [
  419. { required: true, message: "限购次数不能为空" }
  420. ],
  421. }
  422. };
  423. },
  424. created() {
  425. this.getDicts("common_status").then((response) => {
  426. this.statusOptions = response.data;
  427. });
  428. this.getDicts("store_product_package_cate").then((response) => {
  429. this.cateOptions = response.data;
  430. });
  431. this.getDicts("store_pay_type").then((response) => {
  432. this.storePayTypeOptions = response.data;
  433. });
  434. this.getDicts('coupon_installment_switch').then(response=>{
  435. this.icgEnableOptions = response.data;
  436. })
  437. this.getList();
  438. this.loadStoreCouponList();
  439. },
  440. computed:{
  441. icgEnableModel: {
  442. get(){
  443. return this.form.icgEnable?.toString();
  444. },
  445. set(newVal){
  446. this.form.icgEnable = newVal;
  447. }
  448. }
  449. },
  450. methods: {
  451. loadStoreCouponList(){
  452. listAllAvailable().then(response=>{
  453. this.icgCouponsOptions=response.data;
  454. })
  455. },
  456. handleProductCountChange(row){
  457. row.money=row.count*row.price;
  458. this.$forceUpdate();
  459. this.compute();
  460. },
  461. handleProductDelete(row){
  462. this.products.splice(this.products.findIndex(item => item.id === row.id), 1)
  463. this.compute();
  464. },
  465. compute(){
  466. this.totalMoney=0;
  467. var that=this;
  468. this.products.forEach (function (value) {
  469. that.totalMoney += value.money;
  470. });
  471. that.totalMoney=that.totalMoney.toFixed(2);
  472. },
  473. selectProduct(row){
  474. console.log(row);
  475. for(var i=0;i<this.products.length;i++){
  476. if(this.products[i].id==row.id){
  477. return;
  478. }
  479. }
  480. row.count=1;
  481. row.money=row.count*row.price;
  482. this.products.push(row);
  483. this.compute();
  484. },
  485. handleAddProduct(){
  486. this.product.open=true;
  487. // setTimeout(() => {
  488. // this.$refs.product.getData(1);
  489. // }, 200);
  490. },
  491. handleAvatarSuccess(res, file) {
  492. if(res.code==200){
  493. this.form.imgUrl=res.url;
  494. }
  495. else{
  496. this.msgError(res.msg);
  497. }
  498. },
  499. beforeAvatarUpload(file) {
  500. const isLt1M = file.size / 1024 / 1024 < 1;
  501. if (!isLt1M) {
  502. this.$message.error('上传图片大小不能超过 1MB!');
  503. }
  504. return isLt1M;
  505. },
  506. updateText(text){
  507. this.form.content=text;
  508. },
  509. /** 查询商品组合套餐列表 */
  510. getList() {
  511. this.loading = true;
  512. listStoreProductPackage(this.queryParams).then(response => {
  513. this.storeProductPackageList = response.rows;
  514. this.total = response.total;
  515. this.loading = false;
  516. });
  517. },
  518. // 取消按钮
  519. cancel() {
  520. this.open = false;
  521. this.reset();
  522. },
  523. // 表单重置
  524. reset() {
  525. this.form = {
  526. packageId: null,
  527. title: null,
  528. descs: null,
  529. content: null,
  530. imgUrl: null,
  531. images: null,
  532. money: null,
  533. payMoney: null,
  534. companyId: null,
  535. companyUserId: null,
  536. payType:"1",
  537. limitCount:0,
  538. cateId:"0",
  539. status:"1",
  540. icgEnable: "0",
  541. productList:null,
  542. icgCouponsId: [],
  543. icgMonth: 0,
  544. icgUrl: null,
  545. icgMark: null,
  546. };
  547. this.products=[];
  548. this.photoArr=[];
  549. this.imageArr=[];
  550. this.resetForm("form");
  551. },
  552. /** 搜索按钮操作 */
  553. handleQuery() {
  554. this.queryParams.pageNum = 1;
  555. this.getList();
  556. },
  557. /** 重置按钮操作 */
  558. resetQuery() {
  559. this.resetForm("queryForm");
  560. this.handleQuery();
  561. },
  562. // 多选框选中数据
  563. handleSelectionChange(selection) {
  564. this.ids = selection.map(item => item.packageId)
  565. this.single = selection.length!==1
  566. this.multiple = !selection.length
  567. },
  568. /** 新增按钮操作 */
  569. handleAdd() {
  570. this.reset();
  571. this.open = true;
  572. this.title = "添加商品组合套餐";
  573. setTimeout(() => {
  574. this.$refs.myeditor.setText("");
  575. }, 200);
  576. },
  577. /** 修改按钮操作 */
  578. handleUpdate(row) {
  579. this.reset();
  580. const packageId = row.packageId || this.ids
  581. getStoreProductPackage(packageId).then(response => {
  582. this.form = response.data;
  583. this.open = true;
  584. this.title = "修改商品组合套餐";
  585. this.products=this.form.productList;
  586. for(var i=0;i<this.products.length;i++){
  587. this.products[i].money=this.products[i].count*this.products[i].price;
  588. }
  589. this.compute();
  590. setTimeout(() => {
  591. if(this.form.content==null){
  592. this.$refs.myeditor.setText("");
  593. }
  594. else{
  595. this.$refs.myeditor.setText(this.form.content);
  596. }
  597. }, 200);
  598. this.form.payType = response.data.payType.toString();
  599. this.form.status = response.data.status.toString();
  600. if(this.form.imgUrl!=null){
  601. this.imageArr=this.form.imgUrl.split(",");
  602. }
  603. if(this.form.images!=null){
  604. this.photoArr=this.form.images.split(",");
  605. }
  606. if(this.form.cateId!=null){
  607. this.form.cateId = response.data.cateId.toString();
  608. }
  609. this.$forceUpdate();
  610. });
  611. },
  612. /** 提交按钮 */
  613. submitForm() {
  614. this.form.productList=[];
  615. this.products.forEach((item) => {
  616. var data={id:item.id,count:item.count}
  617. this.form.productList.push(data)
  618. })
  619. // console.log(this.form)
  620. // return;
  621. this.$refs["form"].validate(valid => {
  622. if (valid) {
  623. if (this.form.packageId != null) {
  624. updateStoreProductPackage(this.form).then(response => {
  625. if (response.code === 200) {
  626. this.msgSuccess("修改成功");
  627. this.open = false;
  628. this.getList();
  629. }
  630. });
  631. } else {
  632. addStoreProductPackage(this.form).then(response => {
  633. if (response.code === 200) {
  634. this.msgSuccess("新增成功");
  635. this.open = false;
  636. this.getList();
  637. }
  638. });
  639. }
  640. }
  641. });
  642. },
  643. /** 删除按钮操作 */
  644. handleDelete(row) {
  645. const packageIds = row.packageId || this.ids;
  646. this.$confirm('是否确认删除商品组合套餐编号为"' + packageIds + '"的数据项?', "警告", {
  647. confirmButtonText: "确定",
  648. cancelButtonText: "取消",
  649. type: "warning"
  650. }).then(function() {
  651. return delStoreProductPackage(packageIds);
  652. }).then(() => {
  653. this.getList();
  654. this.msgSuccess("删除成功");
  655. }).catch(function() {});
  656. },
  657. /** 导出按钮操作 */
  658. handleExport() {
  659. const queryParams = this.queryParams;
  660. this.$confirm('是否确认导出所有商品组合套餐数据项?', "警告", {
  661. confirmButtonText: "确定",
  662. cancelButtonText: "取消",
  663. type: "warning"
  664. }).then(function() {
  665. return exportStoreProductPackage(queryParams);
  666. }).then(response => {
  667. this.download(response.msg);
  668. }).catch(function() {});
  669. },
  670. handleUpdateMore(row){
  671. this.title = "批量修改套餐状态";
  672. const packageIds = row.packageId || this.ids;
  673. this.form1.packageIds=packageIds;
  674. this.open1 = true;
  675. },
  676. // 取消按钮
  677. cancel1() {
  678. this.open = false;
  679. this.reset();
  680. },
  681. // 表单重置
  682. reset1() {
  683. this.form1 = {
  684. status:"1",
  685. packageIds:[],
  686. };
  687. this.resetForm("form1");
  688. },
  689. /** 提交按钮 */
  690. submitForm1() {
  691. if(this.form1.status==null){
  692. this.msgError("请选择套餐状态");
  693. return;
  694. }
  695. this.$refs["form1"].validate(valid => {
  696. if (valid) {
  697. if (this.form1.packageIds != null) {
  698. modifyStoreProductPackages(this.form1).then(response => {
  699. if (response.code === 200) {
  700. this.msgSuccess("操作成功");
  701. this.open1 = false;
  702. this.getList();
  703. }
  704. });
  705. }
  706. }
  707. });
  708. },
  709. }
  710. };
  711. </script>
  712. <style scoped lang="scss">
  713. .items{
  714. margin: 5px 0px;
  715. display: flex;
  716. flex-direction: row;
  717. align-items: center;
  718. justify-content: flex-start;
  719. .pic{
  720. width:60px;
  721. height:60px;
  722. }
  723. .goods-content{
  724. margin-left: 10px;
  725. max-width: 200px;
  726. text-align: left;
  727. .goods-title{
  728. overflow:hidden;
  729. white-space: nowrap;
  730. text-overflow: ellipsis;
  731. -o-text-overflow:ellipsis;
  732. }
  733. }
  734. }
  735. </style>