index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="商品名称" prop="goodsName">
  5. <el-input
  6. v-model="queryParams.goodsName"
  7. placeholder="请输入商品名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="商品分类" prop="goodsType">
  14. <el-select v-model="queryParams.goodsType" placeholder="请选择商品分类" clearable size="small">
  15. <el-option
  16. v-for="dict in goodsTypeOptions"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. />
  21. </el-select>
  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="dict in statusOptions"
  27. :key="dict.dictValue"
  28. :label="dict.dictLabel"
  29. :value="dict.dictValue"
  30. />
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="所属小程序" prop="appId">
  34. <el-select style="width: 240px" v-model="queryParams.appId" placeholder="请选择所属小程序" clearable size="small">
  35. <el-option
  36. v-for="dict in appMallOptions"
  37. :key="dict.appid"
  38. :label="dict.name + '(' + dict.appid + ')'"
  39. :value="dict.appid"
  40. />
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item>
  44. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  45. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  46. </el-form-item>
  47. </el-form>
  48. <el-row :gutter="10" class="mb8">
  49. <el-col :span="1.5">
  50. <el-button
  51. type="primary"
  52. plain
  53. icon="el-icon-plus"
  54. size="mini"
  55. @click="handleAdd"
  56. v-hasPermi="['his:integralGoods:add']"
  57. >新增</el-button>
  58. </el-col>
  59. <el-col :span="1.5">
  60. <el-button
  61. type="success"
  62. plain
  63. icon="el-icon-edit"
  64. size="mini"
  65. :disabled="single"
  66. @click="handleUpdate"
  67. v-hasPermi="['his:integralGoods:edit']"
  68. >修改</el-button>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button
  72. type="danger"
  73. plain
  74. icon="el-icon-delete"
  75. size="mini"
  76. :disabled="multiple"
  77. @click="handleDelete"
  78. v-hasPermi="['his:integralGoods:remove']"
  79. >删除</el-button>
  80. </el-col>
  81. <el-col :span="1.5">
  82. <el-button
  83. type="warning"
  84. plain
  85. icon="el-icon-download"
  86. size="mini"
  87. :loading="exportLoading"
  88. @click="handleExport"
  89. v-hasPermi="['his:integralGoods:export']"
  90. >导出</el-button>
  91. </el-col>
  92. <el-col :span="1.5">
  93. <el-button
  94. type="info"
  95. plain
  96. icon="el-icon-upload2"
  97. size="mini"
  98. @click="handleImport"
  99. v-hasPermi="['his:integralGoods:handleImport']"
  100. >导入</el-button>
  101. </el-col>
  102. <el-col :span="1.5">
  103. <el-button
  104. type="primary"
  105. plain
  106. icon="el-icon-edit-outline"
  107. size="mini"
  108. :disabled="multiple"
  109. @click="handleBatchUpdate"
  110. v-hasPermi="['his:integralGoods:edit']"
  111. >批量修改积分和金额</el-button>
  112. </el-col>
  113. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  114. </el-row>
  115. <el-table v-loading="loading" border :data="integralGoodsList" @selection-change="handleSelectionChange">
  116. <el-table-column type="selection" width="55" align="center" />
  117. <el-table-column label="编号" align="center" prop="goodsId" />
  118. <el-table-column label="封面图" align="center" prop="imgUrl" >
  119. <template slot-scope="scope">
  120. <el-popover
  121. placement="right"
  122. title=""
  123. trigger="hover"
  124. >
  125. <img slot="reference" :src="scope.row.imgUrl" width="100">
  126. <img :src="scope.row.imgUrl" style="max-width: 150px;">
  127. </el-popover>
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="商品名称" align="center" prop="goodsName" />
  131. <el-table-column label="原价" align="center" prop="otPrice" />
  132. <el-table-column label="商品分类" align="center" prop="goodsType">
  133. <template slot-scope="scope">
  134. <dict-tag :options="goodsTypeOptions" :value="scope.row.goodsType"/>
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="状态" align="center" prop="status">
  138. <template slot-scope="scope">
  139. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  140. </template>
  141. </el-table-column>
  142. <el-table-column label="所需积分" align="center" prop="integral" />
  143. <el-table-column label="需支付金额" align="center" prop="cash" />
  144. <el-table-column label="排序" align="center" prop="sort" />
  145. <el-table-column label="库存" align="center" prop="stock" />
  146. <el-table-column label="创建时间" align="center" prop="createTime" width="180"/>
  147. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150">
  148. <template slot-scope="scope">
  149. <el-button
  150. size="mini"
  151. type="text"
  152. icon="el-icon-edit"
  153. @click="handleUpdate(scope.row)"
  154. v-hasPermi="['his:integralGoods:edit']"
  155. >修改</el-button>
  156. <el-button
  157. size="mini"
  158. type="text"
  159. @click="handledetails(scope.row)"
  160. >详情
  161. </el-button>
  162. <el-button
  163. size="mini"
  164. type="text"
  165. icon="el-icon-delete"
  166. @click="handleDelete(scope.row)"
  167. v-hasPermi="['his:integralGoods:remove']"
  168. >删除</el-button>
  169. </template>
  170. </el-table-column>
  171. </el-table>
  172. <pagination
  173. v-show="total>0"
  174. :total="total"
  175. :page.sync="queryParams.pageNum"
  176. :limit.sync="queryParams.pageSize"
  177. @pagination="getList"
  178. />
  179. <!-- 添加或修改积分商品对话框 -->
  180. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  181. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  182. <el-form-item label="商品名称" prop="goodsName">
  183. <el-input v-model="form.goodsName" placeholder="请输入商品名称" />
  184. </el-form-item>
  185. <el-form-item label="商品分类" prop="goodsType">
  186. <el-select v-model="form.goodsType" placeholder="请选择商品分类">
  187. <el-option
  188. v-for="dict in goodsTypeOptions"
  189. :key="dict.dictValue"
  190. :label="dict.dictLabel"
  191. :value="parseInt(dict.dictValue)"
  192. ></el-option>
  193. </el-select>
  194. </el-form-item>
  195. <el-form-item label="商品图片" prop="imgUrl">
  196. <Material v-model="imageArr" type="image" :num="1" :width="150" :height="150" />
  197. </el-form-item>
  198. <el-form-item label="轮播图" prop="images">
  199. <Material v-model="photoArr" type="image" :num="10" :width="150" :height="150" />
  200. </el-form-item>
  201. <el-form-item label="原价" prop="otPrice">
  202. <el-input-number v-model="form.otPrice" :precision="2" :step="0.1" ></el-input-number>
  203. </el-form-item>
  204. <el-form-item label="所需积分" prop="integral">
  205. <el-input-number v-model="form.integral" :min="1" label="所需积分"></el-input-number>
  206. </el-form-item>
  207. <el-form-item label="支付金额" prop="cash">
  208. <el-input-number v-model="form.cash" :min="0" :precision="2" :step="0.1" label="需支付金额"></el-input-number>
  209. </el-form-item>
  210. <el-form-item label="商品编号" prop="barCode">
  211. <el-input v-model="form.barCode" placeholder="请输入商品编号" style="width: 200px;"/>
  212. </el-form-item>
  213. <el-form-item label="排序" prop="sort">
  214. <el-input-number v-model="form.sort" :min="0" label="排序"></el-input-number>
  215. </el-form-item>
  216. <el-form-item label="详情">
  217. <Editor ref="myeditor" @on-text-change="updateText"/>
  218. </el-form-item>
  219. <el-form-item label="库存" prop="stock">
  220. <el-input-number v-model="form.stock" :min="0" label="库存"></el-input-number>
  221. </el-form-item>
  222. <el-form-item label="运费模板" prop="tempId">
  223. <el-select
  224. style="width: 240px"
  225. v-model="form.tempId"
  226. filterable
  227. clearable
  228. placeholder="请选择运费模板"
  229. size="small"
  230. >
  231. <el-option
  232. v-for="(item, index) in templateList"
  233. :key="index"
  234. :value="item.id"
  235. :label="item.name"
  236. />
  237. </el-select>
  238. </el-form-item>
  239. <el-form-item label="状态">
  240. <el-radio-group v-model="form.status">
  241. <el-radio
  242. v-for="dict in statusOptions"
  243. :key="dict.dictValue"
  244. :label="parseInt(dict.dictValue)"
  245. >{{dict.dictLabel}}</el-radio>
  246. </el-radio-group>
  247. </el-form-item>
  248. <el-form-item label="可见范围" prop="visibleScopeArr">
  249. <el-select style="width: 240px" v-model="visibleScopeArr" placeholder="请选择可见范围" size="small" multiple>
  250. <el-option label="APP" value="app" />
  251. <el-option label="小程序" value="mini" />
  252. </el-select>
  253. </el-form-item>
  254. <el-form-item label="所属小程序" prop="appIds">
  255. <el-select style="width: 240px" v-model="appIds" placeholder="请选择所属小程序" clearable size="small" multiple>
  256. <el-option
  257. v-for="dict in appMallOptions"
  258. :key="dict.appid"
  259. :label="dict.name + '(' + dict.appid + ')'"
  260. :value="dict.appid"
  261. />
  262. </el-select>
  263. </el-form-item>
  264. </el-form>
  265. <div slot="footer" class="dialog-footer">
  266. <el-button type="primary" @click="submitForm">确 定</el-button>
  267. <el-button @click="cancel">取 消</el-button>
  268. </div>
  269. </el-dialog>
  270. <el-drawer
  271. :with-header="false"
  272. size="75%"
  273. :title="show.title" :visible.sync="show.open">
  274. <integralGoodsDetails ref="Details" />
  275. </el-drawer>
  276. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  277. <el-upload
  278. ref="upload"
  279. :limit="1"
  280. accept=".xlsx, .xls"
  281. :headers="upload.headers"
  282. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  283. :disabled="upload.isUploading"
  284. :on-progress="handleFileUploadProgress"
  285. :on-success="handleFileSuccess"
  286. :auto-upload="false"
  287. drag
  288. >
  289. <i class="el-icon-upload"></i>
  290. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  291. <div class="el-upload__tip text-center" slot="tip">
  292. <div class="el-upload__tip" slot="tip">
  293. <!-- <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的数据 -->
  294. </div>
  295. <span>仅允许导入xls、xlsx格式文件。</span>
  296. <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
  297. </div>
  298. </el-upload>
  299. <div slot="footer" class="dialog-footer">
  300. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  301. <el-button @click="upload.open = false">取 消</el-button>
  302. </div>
  303. </el-dialog>
  304. <!-- 批量修改积分和金额对话框 -->
  305. <el-dialog :title="batchTitle" :visible.sync="batchOpen" width="500px" append-to-body>
  306. <el-form ref="batchForm" :model="batchForm" :rules="batchRules" label-width="120px">
  307. <el-form-item label="所需积分" prop="integral">
  308. <el-input-number v-model="batchForm.integral" :min="1" placeholder="请输入所需积分"></el-input-number>
  309. </el-form-item>
  310. <el-form-item label="需支付金额" prop="cash">
  311. <el-input-number v-model="batchForm.cash" :min="0" :precision="2" :step="0.1" placeholder="请输入支付金额"></el-input-number>
  312. </el-form-item>
  313. <el-alert
  314. title="至少填写一项,留空项将不修改"
  315. type="info"
  316. :closable="false"
  317. show-icon
  318. />
  319. </el-form>
  320. <div slot="footer" class="dialog-footer">
  321. <el-button type="primary" @click="submitBatchForm" :loading="batchLoading">确 定</el-button>
  322. <el-button @click="batchOpen = false">取 消</el-button>
  323. </div>
  324. </el-dialog>
  325. </div>
  326. </template>
  327. <script>
  328. import { importTemplate,listIntegralGoods, getIntegralGoods, delIntegralGoods, addIntegralGoods, updateIntegralGoods, exportIntegralGoods, batchUpdateIntegralGoods } from "@/api/his/integralGoods";
  329. import Material from '@/components/Material';
  330. import Editor from '@/components/Editor/wang';
  331. import { getToken } from "@/utils/auth";
  332. import integralGoodsDetails from '../../components/his/integralGoodsDetails';
  333. import { list as getAppMallOptions } from '@/api/course/coursePlaySourceConfig'
  334. import { getAllShippingTemplates } from "@/api/hisStore/shippingTemplates";
  335. export default {
  336. name: "IntegralGoods",
  337. components: {Material,Editor,integralGoodsDetails},
  338. watch: {
  339. imageArr: function(val) {
  340. this.form.imgUrl = val.join(',')
  341. },
  342. photoArr: function(val) {
  343. this.form.images = val.join(',')
  344. }
  345. },
  346. data() {
  347. return {
  348. appIds:[], // 选择的小程序
  349. visibleScopeArr: ['app', 'mini'],
  350. // 小程序列表
  351. appMallOptions:[],
  352. templateList: [],
  353. show:{
  354. open:false,
  355. },
  356. upload: {
  357. // 是否显示弹出层
  358. open: false,
  359. // 弹出层标题
  360. title: "",
  361. // 是否禁用上传
  362. isUploading: false,
  363. // 是否更新已经存在的用户数据
  364. updateSupport: 0,
  365. // 设置上传的请求头部
  366. headers: { Authorization: "Bearer " + getToken() },
  367. // 上传的地址
  368. url: process.env.VUE_APP_BASE_API + "/his/integralGoods/importData"
  369. },
  370. // 批量修改
  371. batchOpen: false,
  372. batchTitle: "批量修改积分和金额",
  373. batchLoading: false,
  374. batchForm: {
  375. integral: null,
  376. cash: null
  377. },
  378. batchRules: {
  379. integral: [
  380. {
  381. validator: (rule, value, callback) => {
  382. if (this.batchForm.integral === null && this.batchForm.cash === null) {
  383. callback(new Error('至少需要填写所需积分或需支付金额中的一项'));
  384. } else {
  385. callback();
  386. }
  387. },
  388. trigger: 'change'
  389. }
  390. ],
  391. cash: [
  392. {
  393. validator: (rule, value, callback) => {
  394. if (this.batchForm.integral === null && this.batchForm.cash === null) {
  395. callback(new Error('至少需要填写所需积分或需支付金额中的一项'));
  396. } else {
  397. callback();
  398. }
  399. },
  400. trigger: 'change'
  401. }
  402. ]
  403. },
  404. photoArr:[],
  405. imageArr:[],
  406. // 遮罩层
  407. loading: true,
  408. // 导出遮罩层
  409. exportLoading: false,
  410. // 选中数组
  411. ids: [],
  412. // 非单个禁用
  413. single: true,
  414. // 非多个禁用
  415. multiple: true,
  416. // 显示搜索条件
  417. showSearch: true,
  418. // 总条数
  419. total: 0,
  420. // 积分商品表格数据
  421. integralGoodsList: [],
  422. // 弹出层标题
  423. title: "",
  424. // 是否显示弹出层
  425. open: false,
  426. // 商品分类字典
  427. goodsTypeOptions: [],
  428. // 状态字典
  429. statusOptions: [],
  430. // 查询参数
  431. queryParams: {
  432. pageNum: 1,
  433. pageSize: 10,
  434. goodsName: null,
  435. goodsType: null,
  436. status: null,
  437. appId: null,
  438. integral: null,
  439. createTime: null
  440. },
  441. // 表单参数
  442. form: {},
  443. // 表单校验
  444. rules: {
  445. imgUrl: [
  446. { required: true, message: "封面图不能为空", trigger: "submit" }
  447. ],
  448. goodsName: [
  449. { required: true, message: "商品名称不能为空", trigger: "submit" }
  450. ],
  451. barCode: [
  452. { required: true, message: "商品编号不能为空", trigger: "blur" }
  453. ]
  454. }
  455. };
  456. },
  457. created() {
  458. // 查询小程序
  459. this.getAppMallOptions();
  460. this.loadShippingTemplates();
  461. this.getList();
  462. this.getDicts("sys_integral_goods_type").then(response => {
  463. this.goodsTypeOptions = response.data;
  464. });
  465. this.getDicts("sys_company_status").then(response => {
  466. this.statusOptions = response.data;
  467. });
  468. },
  469. methods: {
  470. loadShippingTemplates() {
  471. getAllShippingTemplates().then(response => {
  472. this.templateList = response.data || [];
  473. });
  474. },
  475. getAppMallOptions() {
  476. getAppMallOptions({pageNum:1,pageSize:100}).then(response => {
  477. this.appMallOptions = response.rows;
  478. })
  479. },
  480. handledetails(row){
  481. this.show.open=true;
  482. setTimeout(() => {
  483. this.$refs.Details.getDetails(row.goodsId);
  484. }, 1);
  485. },
  486. /** 导入按钮操作 */
  487. handleImport() {
  488. this.upload.title = "导入";
  489. this.upload.open = true;
  490. },
  491. /** 下载模板操作 */
  492. importTemplate() {
  493. importTemplate().then(response => {
  494. this.download(response.msg);
  495. });
  496. },
  497. // 文件上传中处理
  498. handleFileUploadProgress(event, file, fileList) {
  499. this.upload.isUploading = true;
  500. },
  501. // 文件上传成功处理
  502. handleFileSuccess(response, file, fileList) {
  503. this.upload.open = false;
  504. this.upload.isUploading = false;
  505. this.$refs.upload.clearFiles();
  506. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  507. this.getList();
  508. },
  509. // 提交上传文件
  510. submitFileForm() {
  511. this.$refs.upload.submit();
  512. },
  513. /** 查询积分商品列表 */
  514. getList() {
  515. this.loading = true;
  516. listIntegralGoods(this.queryParams).then(response => {
  517. this.integralGoodsList = response.rows;
  518. this.total = response.total;
  519. this.loading = false;
  520. });
  521. },
  522. updateText(text){
  523. this.form.descs=text
  524. },
  525. // 取消按钮
  526. cancel() {
  527. this.open = false;
  528. this.reset();
  529. },
  530. // 表单重置
  531. reset() {
  532. this.form = {
  533. goodsId: null,
  534. imgUrl: null,
  535. images: null,
  536. goodsName: null,
  537. otPrice: null,
  538. goodsType: null,
  539. status: 0,
  540. integral: null,
  541. cash: null,
  542. sort: null,
  543. stock: null,
  544. descs: null,
  545. createTime: null,
  546. visibleScope: 'app,mini',
  547. tempId: null
  548. };
  549. this.appIds = [];
  550. this.visibleScopeArr = ['app', 'mini'];
  551. this.resetForm("form");
  552. },
  553. /** 搜索按钮操作 */
  554. handleQuery() {
  555. this.queryParams.pageNum = 1;
  556. this.getList();
  557. },
  558. /** 重置按钮操作 */
  559. resetQuery() {
  560. this.resetForm("queryForm");
  561. this.handleQuery();
  562. },
  563. // 多选框选中数据
  564. handleSelectionChange(selection) {
  565. this.ids = selection.map(item => item.goodsId)
  566. this.single = selection.length!==1
  567. this.multiple = !selection.length
  568. },
  569. /** 新增按钮操作 */
  570. handleAdd() {
  571. this.reset();
  572. this.open = true;
  573. this.title = "添加积分商品";
  574. //新增
  575. setTimeout(() => {
  576. this.$refs.myeditor.setText("");
  577. }, 500);
  578. },
  579. /** 修改按钮操作 */
  580. handleUpdate(row) {
  581. this.reset();
  582. const goodsId = row.goodsId || this.ids
  583. getIntegralGoods(goodsId).then(response => {
  584. this.form = response.data;
  585. this.open = true;
  586. this.title = "修改积分商品";
  587. if(this.form.imgUrl!=null){
  588. this.imageArr=this.form.imgUrl.split(",");
  589. }
  590. if(this.form.images!=null){
  591. this.photoArr=this.form.images.split(",");
  592. }
  593. this.appIds = this.form.appIds ? this.form.appIds.split(',') : [];
  594. this.visibleScopeArr = this.form.visibleScope ? this.form.visibleScope.split(',') : ['app', 'mini'];
  595. //修改按钮
  596. setTimeout(() => {
  597. if(this.form.descs==null){
  598. this.$refs.myeditor.setText("");
  599. }
  600. else{
  601. this.$refs.myeditor.setText(this.form.descs);
  602. }
  603. }, 1);
  604. });
  605. },
  606. /** 提交按钮 */
  607. submitForm() {
  608. this.$refs["form"].validate(valid => {
  609. if (valid) {
  610. if (!this.visibleScopeArr || this.visibleScopeArr.length === 0) {
  611. this.msgError("请选择可见范围");
  612. return;
  613. }
  614. // 小程序
  615. const params = {
  616. ...this.form,
  617. appIds: this.appIds.join(','),
  618. visibleScope: this.visibleScopeArr.join(',')
  619. };
  620. if (this.form.goodsId != null) {
  621. updateIntegralGoods(params).then(response => {
  622. this.msgSuccess("修改成功");
  623. this.open = false;
  624. this.reset();
  625. this.getList();
  626. });
  627. } else {
  628. addIntegralGoods(params).then(response => {
  629. this.msgSuccess("新增成功");
  630. this.open = false;
  631. this.reset();
  632. this.getList();
  633. });
  634. }
  635. }
  636. });
  637. },
  638. /** 删除按钮操作 */
  639. handleDelete(row) {
  640. const goodsIds = row.goodsId || this.ids;
  641. this.$confirm('是否确认删除积分商品编号为"' + goodsIds + '"的数据项?', "警告", {
  642. confirmButtonText: "确定",
  643. cancelButtonText: "取消",
  644. type: "warning"
  645. }).then(function() {
  646. return delIntegralGoods(goodsIds);
  647. }).then(() => {
  648. this.getList();
  649. this.msgSuccess("删除成功");
  650. }).catch(() => {});
  651. },
  652. /** 批量修改按钮操作 */
  653. handleBatchUpdate() {
  654. this.batchForm = {
  655. integral: null,
  656. cash: null
  657. };
  658. this.batchOpen = true;
  659. },
  660. /** 提交批量修改 */
  661. submitBatchForm() {
  662. this.$refs["batchForm"].validate(valid => {
  663. if (valid) {
  664. const params = {
  665. goodsIds: this.ids,
  666. integral: this.batchForm.integral,
  667. cash: this.batchForm.cash
  668. };
  669. this.batchLoading = true;
  670. batchUpdateIntegralGoods(params).then(response => {
  671. this.msgSuccess("批量修改成功");
  672. this.batchOpen = false;
  673. this.batchLoading = false;
  674. this.getList();
  675. }).catch(() => {
  676. this.batchLoading = false;
  677. });
  678. }
  679. });
  680. },
  681. /** 导出按钮操作 */
  682. handleExport() {
  683. const queryParams = this.queryParams;
  684. this.$confirm('是否确认导出所有积分商品数据项?', "警告", {
  685. confirmButtonText: "确定",
  686. cancelButtonText: "取消",
  687. type: "warning"
  688. }).then(() => {
  689. this.exportLoading = true;
  690. return exportIntegralGoods(queryParams);
  691. }).then(response => {
  692. this.download(response.msg);
  693. this.exportLoading = false;
  694. }).catch(() => {});
  695. }
  696. }
  697. };
  698. </script>