coupon.vue 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833
  1. <template>
  2. <div>
  3. <el-tabs v-model="activeName" @tab-click="handleClick">
  4. <el-tab-pane label="平台优惠券" name="seventh">
  5. <div style="display: flex;justify-content: space-between;">
  6. <div>
  7. <span>优惠券状态:</span>
  8. <el-select
  9. :clearable="true"
  10. @change="refreshShop"
  11. v-model="selectState"
  12. placeholder="请选择状态"
  13. >
  14. <el-option label="待审核" :value="0"></el-option>
  15. <el-option label="已发布" :value="1"></el-option>
  16. <el-option label="已撤销" :value="2"></el-option>
  17. </el-select>
  18. </div>
  19. <div>
  20. <el-button
  21. size="mini"
  22. type="primary"
  23. icon="document"
  24. @click="refresh"
  25. >刷新</el-button
  26. >
  27. <el-button
  28. style="margin:0 0 20px 10px;"
  29. :disabled="!isAuth('coupon:add')"
  30. size="mini"
  31. type="primary"
  32. icon="document"
  33. @click="classifyStair()"
  34. >添加优惠券</el-button
  35. >
  36. <el-button
  37. style="margin:0 0 20px 10px;"
  38. :disabled="!isAuth('coupon:log')"
  39. size="mini"
  40. type="primary"
  41. icon="document"
  42. @click="couponLog()"
  43. >查看优惠券日志</el-button
  44. >
  45. </div>
  46. </div>
  47. <el-table v-loading="tableDataLoading" :data="tableData.list">
  48. <el-table-column prop="couponId" label="编号" width="80">
  49. </el-table-column>
  50. <el-table-column prop="couponName" label="优惠券名称">
  51. </el-table-column>
  52. <el-table-column prop="couponPicture" label="图片">
  53. <template slot-scope="scope">
  54. <img
  55. :src="scope.row.couponPicture"
  56. alt=""
  57. width="40"
  58. height="40"
  59. />
  60. </template>
  61. </el-table-column>
  62. <el-table-column prop="money" label="优惠券金额"> </el-table-column>
  63. <el-table-column prop="minMoney" label="最低消费"> </el-table-column>
  64. <el-table-column prop="endDate" label="有效天数"> </el-table-column>
  65. <el-table-column prop="needIntegral" label="兑换积分">
  66. </el-table-column>
  67. <el-table-column prop="state" label="状态">
  68. <template slot-scope="scope">
  69. <span v-if="scope.row.state == 0">待审核</span>
  70. <span v-if="scope.row.state == 1">已发布</span>
  71. <span v-if="scope.row.state == 2">已撤销</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="操作" width="250">
  75. <template slot-scope="scope">
  76. <el-button
  77. v-if="scope.row.state == 1"
  78. :disabled="!isAuth('coupon:update')"
  79. size="mini"
  80. type="primary"
  81. icon="document"
  82. @click="songCoupon(scope.row)"
  83. >赠送
  84. </el-button>
  85. <el-button
  86. v-if="superAdmin == 1 && scope.row.state == 1"
  87. size="mini"
  88. type="primary"
  89. :disabled="!isAuth('coupon:update')"
  90. @click="compile(scope.$index, scope.row)"
  91. >编辑
  92. </el-button>
  93. <el-button
  94. v-if="scope.row.state == 1"
  95. size="mini"
  96. type="danger"
  97. :disabled="!isAuth('coupon:delete')"
  98. @click="deleteStair(scope.row)"
  99. >删除
  100. </el-button>
  101. <el-button
  102. v-if="superAdmin == 1 && scope.row.state == 0"
  103. size="mini"
  104. type="primary"
  105. @click="announceStair(scope.row, 1)"
  106. >发布
  107. </el-button>
  108. <el-button
  109. v-if="superAdmin == 1 && scope.row.state == 0"
  110. size="mini"
  111. type="danger"
  112. @click="announceStair(scope.row, 2)"
  113. >撤销
  114. </el-button>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <div style="text-align: center;margin-top: 10px;">
  119. <el-pagination
  120. @size-change="handleSizeChange"
  121. @current-change="handleCurrentChange"
  122. :page-sizes="[10, 20, 30, 40]"
  123. :page-size="limit"
  124. :current-page="page"
  125. layout="total,sizes, prev, pager, next"
  126. :total="tableData.totalCount"
  127. >
  128. </el-pagination>
  129. </div>
  130. </el-tab-pane>
  131. <el-tab-pane label="商家优惠券" name="youhuiquan">
  132. <div style="position: relative;display: inline-block;margin: 10px 0px;">
  133. <span>商户名称:</span>
  134. <el-input
  135. style="width: 200px;"
  136. @keydown.enter.native="animeDat"
  137. placeholder="请输入商户名称"
  138. v-model="shopName"
  139. >
  140. </el-input
  141. >&nbsp;&nbsp;
  142. <el-button
  143. size="mini"
  144. type="primary"
  145. icon="document"
  146. @click="refreshShop"
  147. >查询</el-button
  148. >
  149. <el-button
  150. style="margin:0 0 20px 10px;"
  151. :disabled="!isAuth('coupon:add')"
  152. size="mini"
  153. type="primary"
  154. icon="document"
  155. @click="classifyStair()"
  156. >添加优惠券</el-button
  157. >
  158. </div>
  159. <el-table v-loading="tableDataLoading" :data="tableData.list">
  160. <el-table-column prop="couponId" label="编号" width="80">
  161. </el-table-column>
  162. <el-table-column prop="shopName" label="商户名称"> </el-table-column>
  163. <el-table-column prop="couponName" label="优惠券名称">
  164. </el-table-column>
  165. <el-table-column prop="couponPicture" label="图片">
  166. <template slot-scope="scope">
  167. <img
  168. :src="scope.row.couponPicture"
  169. alt=""
  170. width="40"
  171. height="40"
  172. />
  173. </template>
  174. </el-table-column>
  175. <el-table-column prop="money" label="优惠券金额"> </el-table-column>
  176. <el-table-column prop="minMoney" label="最低消费"> </el-table-column>
  177. <el-table-column prop="endDate" label="有效天数"> </el-table-column>
  178. <!-- <el-table-column prop="needIntegral" label="兑换积分">
  179. </el-table-column> -->
  180. <el-table-column label="操作" width="250">
  181. <template slot-scope="scope">
  182. <el-button
  183. style="margin-left:15px;"
  184. :disabled="!isAuth('coupon:update')"
  185. size="mini"
  186. type="primary"
  187. icon="document"
  188. @click="songCoupon(scope.row)"
  189. >赠送</el-button
  190. >
  191. <el-button
  192. size="mini"
  193. type="primary"
  194. :disabled="!isAuth('coupon:update')"
  195. @click="compile(scope.$index, scope.row)"
  196. >编辑
  197. </el-button>
  198. <el-button
  199. size="mini"
  200. type="danger"
  201. :disabled="!isAuth('coupon:delete')"
  202. @click="deleteStair(scope.row)"
  203. >删除
  204. </el-button>
  205. </template>
  206. </el-table-column>
  207. </el-table>
  208. <div style="text-align: center;margin-top: 10px;">
  209. <el-pagination
  210. @size-change="handleSizeChange"
  211. @current-change="handleCurrentChange"
  212. :page-sizes="[10, 20, 30, 40]"
  213. :page-size="limit"
  214. :current-page="page"
  215. layout="total,sizes, prev, pager, next"
  216. :total="tableData.totalCount"
  217. >
  218. </el-pagination>
  219. </div>
  220. </el-tab-pane>
  221. </el-tabs>
  222. <!-- 查看优惠券日志 -->
  223. <el-dialog
  224. title="查看优惠券日志"
  225. custom-class="couponLog"
  226. :visible.sync="couponLogVisible"
  227. center
  228. >
  229. <el-table v-loading="couponLogLoading" :data="couponLogTable">
  230. <el-table-column prop="couponId" label="编号" width="80">
  231. </el-table-column>
  232. <el-table-column prop="couponName" label="优惠券名称">
  233. </el-table-column>
  234. <el-table-column prop="couponPicture" label="图片">
  235. <template slot-scope="scope">
  236. <img :src="scope.row.couponPicture" alt="" width="40" height="40" />
  237. </template>
  238. </el-table-column>
  239. <el-table-column prop="money" label="优惠券金额"> </el-table-column>
  240. <el-table-column prop="minMoney" label="最低消费"> </el-table-column>
  241. <el-table-column prop="endDate" label="有效天数"> </el-table-column>
  242. <el-table-column prop="needIntegral" label="兑换积分">
  243. </el-table-column>
  244. <el-table-column prop="state" label="状态">
  245. <template slot-scope="scope">
  246. <span v-if="scope.row.state == 0">待审核</span>
  247. <span v-if="scope.row.state == 1">已发布</span>
  248. <span v-if="scope.row.state == 2">已撤销</span>
  249. </template>
  250. </el-table-column>
  251. <el-table-column prop="content" label="操作内容"> </el-table-column>
  252. <el-table-column prop="username" label="操作人"> </el-table-column>
  253. <el-table-column prop="createTime" label="操作时间"> </el-table-column>
  254. </el-table>
  255. <div style="text-align: center;margin-top: 10px;">
  256. <el-pagination
  257. @size-change="couponLogSize"
  258. @current-change="couponLogCurrent"
  259. :page-sizes="[10, 20, 30, 40]"
  260. :page-size="couponLogLimit"
  261. :current-page="couponLogPage"
  262. layout="total,sizes, prev, pager, next"
  263. :total="couponLogTotal"
  264. >
  265. </el-pagination>
  266. </div>
  267. <!-- <div slot="footer" class="dialog-footer">
  268. <el-button @click="couponLogVisible = false">取 消</el-button>
  269. <el-button type="primary" @click="startCouponLog()">确 定</el-button>
  270. </div> -->
  271. </el-dialog>
  272. <!-- 添加优惠券 -->
  273. <el-dialog
  274. customClass="discount"
  275. title="添加优惠券"
  276. :visible.sync="dialogFormVisible"
  277. center
  278. >
  279. <div style="display: flex;justify-content: center;">
  280. <div>
  281. <div style="margin-bottom: 10px;" v-if="this.shopId == -1">
  282. <span style="width:150px;display: inline-block;text-align: right;"
  283. >商铺名称:</span
  284. >
  285. <el-input
  286. v-model="shopNames"
  287. placeholder="请选择商铺"
  288. style="width:50%;"
  289. @focus="selectUserId"
  290. ></el-input>
  291. </div>
  292. <div style="margin-bottom: 10px;">
  293. <span style="width: 150px;display: inline-block;text-align: right;"
  294. >优惠券名称:</span
  295. >
  296. <el-input
  297. style="width:50%;"
  298. v-model="couponName"
  299. type="text"
  300. placeholder="请输入优惠券名称"
  301. ></el-input>
  302. </div>
  303. <div style="margin-bottom: 10px;">
  304. <span style="width: 150px;display: inline-block;text-align: right;"
  305. >图片:</span
  306. >
  307. <!-- <el-input style="width:50%;" v-model="couponPicture" type="text" placeholder="请输入图片"></el-input> -->
  308. <div
  309. style=" width:148px;height:148px;background-color: #fbfdff; border: 1px dashed #c0ccda;border-radius: 6px;text-align: center;line-height: 148px;display: inline-block;"
  310. >
  311. <el-upload
  312. class="avatar-uploader"
  313. v-model="couponPicture"
  314. :action="Tupiantou"
  315. :show-file-list="false"
  316. :on-success="handleAvatarSuccess1"
  317. :before-upload="beforeAvatarUpload"
  318. >
  319. <img
  320. v-if="couponPicture"
  321. :src="couponPicture"
  322. class="avatar"
  323. style="width: 148px;height: 148px;"
  324. />
  325. <i
  326. v-else
  327. class="el-icon-plus avatar-uploader-icon"
  328. style="font-size: 28px;color: #8c939d"
  329. ></i>
  330. </el-upload>
  331. </div>
  332. </div>
  333. <div style="margin-bottom: 10px;">
  334. <span style="width: 150px;display: inline-block;text-align: right;"
  335. >优惠券金额:</span
  336. >
  337. <el-input
  338. style="width:50%;"
  339. v-model="money"
  340. type="text"
  341. placeholder="请输入优惠券金额"
  342. ></el-input>
  343. </div>
  344. <div style="margin-bottom: 10px;">
  345. <span style="width: 150px;display: inline-block;text-align: right;"
  346. >最低消费:</span
  347. >
  348. <el-input
  349. style="width:50%;"
  350. v-model="minMoney"
  351. type="text"
  352. placeholder="请输入最低消费"
  353. ></el-input>
  354. </div>
  355. <div style="margin-bottom: 10px;">
  356. <span style="width: 150px;display: inline-block;text-align: right;"
  357. >有效天数:</span
  358. >
  359. <el-input
  360. style="width:50%;"
  361. v-model="endDate"
  362. type="text"
  363. placeholder="请输入有效天数"
  364. ></el-input>
  365. </div>
  366. <div style="margin-bottom: 10px;" v-if="this.shopId == 0">
  367. <span style="width: 150px;display: inline-block;text-align: right;"
  368. >兑换积分:</span
  369. >
  370. <el-input
  371. style="width:50%;"
  372. v-model="needIntegral"
  373. type="text"
  374. placeholder="请输入兑换积分"
  375. ></el-input>
  376. </div>
  377. <span style="color: red;margin-left: 32px;"
  378. >兑换积分初始值为100,是必填项,不填则默认向所有用户发券</span
  379. >
  380. </div>
  381. <div v-loading="allShopLoading" v-if="this.shopId == 0">
  382. <div style="width: 500px;height: 200px;">
  383. <div style="margin-bottom: 10px;">
  384. <span
  385. style="width: 150px;display: inline-block;text-align: right;"
  386. >使用范围:</span
  387. >
  388. <el-checkbox
  389. @change="checkChange($event, '不限制')"
  390. v-model="allMerchant"
  391. >不限制</el-checkbox
  392. >
  393. <el-checkbox
  394. @change="checkChange($event, '部分商家')"
  395. v-model="someMerchant"
  396. >部分商家</el-checkbox
  397. >
  398. </div>
  399. <div style="margin:0 0 10px 80px;" v-if="someMerchant">
  400. <el-input
  401. v-model="selectName"
  402. placeholder="请输入商铺名称"
  403. style="width:50%;"
  404. clearable
  405. @change="shopNameSeache"
  406. ></el-input>
  407. <!-- <el-button
  408. style="margin-left: 15px"
  409. size="medium"
  410. type="primary"
  411. icon="document"
  412. @click="shopNameSeache"
  413. >查询
  414. </el-button> -->
  415. </div>
  416. <div
  417. v-if="someMerchant"
  418. style="margin:0 0 10px 80px;height: 300px;border: 1px solid #ccc;overflow: auto;"
  419. @scroll="handleTreeScroll"
  420. >
  421. <el-tree
  422. class="shop"
  423. ref="tree"
  424. :data="dataTree"
  425. show-checkbox
  426. node-key="shopId"
  427. :props="defaultProps"
  428. @check="treeCheck"
  429. ></el-tree>
  430. <div style="text-align: center;" v-if="allShopListShow">
  431. 数据已全部加载完
  432. </div>
  433. </div>
  434. <div style="margin-bottom: 10px;" v-if="someMerchant">
  435. <span
  436. style="width: 130px;display: inline-block;text-align: right;"
  437. >已选择</span
  438. ><span style="color: red;">{{ selectMerchant.length }}</span
  439. >个商家
  440. </div>
  441. </div>
  442. </div>
  443. </div>
  444. <div slot="footer" class="dialog-footer">
  445. <el-button @click="dialogFormVisible = false">取 消</el-button>
  446. <el-button type="primary" @click="StairNoticeTo()">确 定</el-button>
  447. </div>
  448. </el-dialog>
  449. <!-- 修改优惠券 -->
  450. <el-dialog
  451. customClass="discount"
  452. title="修改优惠券"
  453. :visible.sync="dialogFormVisible1"
  454. center
  455. :before-close="compileClose"
  456. >
  457. <div style="display: flex;justify-content: center;">
  458. <el-form :model="form">
  459. <div style="display: flex;justify-content: center;">
  460. <div>
  461. <el-form-item
  462. label="商铺名称:"
  463. :label-width="formLabelWidth"
  464. v-if="this.shopId == -1"
  465. >
  466. <el-input
  467. v-model="shopNames"
  468. placeholder="请选择商铺"
  469. style="width:50%;"
  470. @focus="selectUserId"
  471. >
  472. </el-input>
  473. </el-form-item>
  474. <el-form-item label="优惠券名称:" :label-width="formLabelWidth">
  475. <el-input
  476. v-model="form.couponName"
  477. style="width:65%;"
  478. ></el-input>
  479. </el-form-item>
  480. <el-form-item label="图片:" :label-width="formLabelWidth">
  481. <!-- <el-input v-model="form.campusDetails" style="width:65%;"></el-input> -->
  482. <div
  483. style=" width:148px;height:148px;background-color: #fbfdff; border: 1px dashed #c0ccda;border-radius: 6px;text-align: center;line-height: 148px;display: inline-block;"
  484. >
  485. <el-upload
  486. class="avatar-uploader"
  487. v-model="form.couponPicture"
  488. :action="Tupiantou"
  489. :show-file-list="false"
  490. :on-success="handleAvatarSuccess2"
  491. :before-upload="beforeAvatarUpload"
  492. >
  493. <img
  494. v-if="form.couponPicture"
  495. :src="form.couponPicture"
  496. class="avatar"
  497. style="width: 148px;height: 148px;"
  498. />
  499. <i
  500. v-else
  501. class="el-icon-plus avatar-uploader-icon"
  502. style="font-size: 28px;color: #8c939d"
  503. ></i>
  504. </el-upload>
  505. </div>
  506. </el-form-item>
  507. <el-form-item label="优惠券金额:" :label-width="formLabelWidth">
  508. <el-input v-model="form.money" style="width:65%;"></el-input>
  509. </el-form-item>
  510. <el-form-item label="最低消费:" :label-width="formLabelWidth">
  511. <el-input v-model="form.minMoney" style="width:65%;"></el-input>
  512. </el-form-item>
  513. <el-form-item label="有效天数:" :label-width="formLabelWidth">
  514. <el-input v-model="form.endDate" style="width:65%;"></el-input>
  515. </el-form-item>
  516. <el-form-item
  517. label="兑换积分:"
  518. :label-width="formLabelWidth"
  519. v-if="this.shopId == 0"
  520. >
  521. <el-input
  522. v-model="form.needIntegral"
  523. style="width:65%;"
  524. ></el-input>
  525. </el-form-item>
  526. <span style="color: red;margin-left: 32px;"
  527. >兑换积分初始值为100,是必填项,不填则默认向所有用户发券</span
  528. >
  529. </div>
  530. <div v-loading="allShopLoading" v-if="this.shopId == 0">
  531. <div style="width: 500px;height: 200px;">
  532. <div style="margin-bottom: 10px;">
  533. <span
  534. style="width: 150px;display: inline-block;text-align: right;"
  535. >使用范围:</span
  536. >
  537. <el-checkbox
  538. @change="checkChange($event, '不限制')"
  539. v-model="allMerchant"
  540. >不限制</el-checkbox
  541. >
  542. <el-checkbox
  543. @change="checkChange($event, '部分商家')"
  544. v-model="someMerchant"
  545. >部分商家</el-checkbox
  546. >
  547. </div>
  548. <div style="margin:0 0 10px 80px;" v-if="someMerchant">
  549. <el-input
  550. v-model="selectName"
  551. placeholder="请输入商铺名称"
  552. style="width:50%;"
  553. clearable
  554. @change="shopNameSeache"
  555. ></el-input>
  556. <!-- <el-button
  557. style="margin-left: 15px"
  558. size="medium"
  559. type="primary"
  560. icon="document"
  561. @click="shopNameSeache"
  562. >查询
  563. </el-button> -->
  564. </div>
  565. <div
  566. v-if="someMerchant"
  567. style="margin:0 0 10px 80px;height: 300px;border: 1px solid #ccc;overflow: auto;"
  568. @scroll="handleTreeScroll"
  569. >
  570. <el-tree
  571. class="shop"
  572. ref="tree"
  573. :data="dataTree"
  574. show-checkbox
  575. node-key="shopId"
  576. :props="defaultProps"
  577. @check="treeCheck"
  578. ></el-tree>
  579. <div style="text-align: center;" v-if="allShopListShow">
  580. 数据已全部加载完
  581. </div>
  582. </div>
  583. <div style="margin-bottom: 10px;" v-if="someMerchant">
  584. <span
  585. style="width: 130px;display: inline-block;text-align: right;"
  586. >已选择</span
  587. ><span style="color: red;">{{ selectMerchant.length }}</span
  588. >个商家
  589. </div>
  590. </div>
  591. </div>
  592. </div>
  593. </el-form>
  594. </div>
  595. <div slot="footer" class="dialog-footer">
  596. <el-button @click="dialogFormVisible1 = false">取 消</el-button>
  597. <el-button type="primary" @click="CompileNoticeTo()">确 定</el-button>
  598. </div>
  599. </el-dialog>
  600. <!-- 赠送优惠券-->
  601. <el-dialog title="赠送优惠券" :visible.sync="dialogFormVisible0" center>
  602. <div style="margin: 10px 0;">
  603. <span style="width: 200px;display: inline-block;text-align: right;"
  604. >选择用户:</span
  605. >
  606. <el-tag
  607. :key="tag"
  608. v-for="(tag, j) in userNameList"
  609. closable
  610. :disable-transitions="false"
  611. @close="couponIdClose1(tag, j)"
  612. >
  613. {{ tag }}
  614. </el-tag>
  615. <el-button class="button-new-tag" size="small" @click="couponIdBtn1()"
  616. >添加</el-button
  617. >
  618. </div>
  619. <div slot="footer" class="dialog-footer">
  620. <el-button @click="dialogFormVisible0 = false">取 消</el-button>
  621. <el-button type="primary" @click="songNoticeTo()">确 定</el-button>
  622. </div>
  623. </el-dialog>
  624. <!-- 用户列表 -->
  625. <el-dialog
  626. title="用户列表"
  627. :visible.sync="dialogFormVisible5"
  628. center
  629. width="80%"
  630. >
  631. <el-input
  632. style="width: 150px;"
  633. @keydown.enter.native="select1"
  634. clearable
  635. placeholder="请输入手机号"
  636. v-model="phone"
  637. >
  638. </el-input
  639. >&nbsp;&nbsp;&nbsp;&nbsp;
  640. <el-input
  641. style="width: 150px;"
  642. @keydown.enter.native="select1"
  643. clearable
  644. placeholder="请输入昵称"
  645. v-model="nickName"
  646. >
  647. </el-input>
  648. <div style="display: inline-block;">
  649. <el-button
  650. style="margin-left:15px;"
  651. size="mini"
  652. type="primary"
  653. icon="document"
  654. @click="select1"
  655. >查询
  656. </el-button>
  657. <el-button
  658. style="margin-left:15px;"
  659. size="mini"
  660. type="primary"
  661. icon="document"
  662. @click="cleans1"
  663. >重置
  664. </el-button>
  665. </div>
  666. <el-button
  667. style="margin-left:15px;"
  668. :disabled="userIdList.length <= 0"
  669. size="mini"
  670. type="primary"
  671. icon="document"
  672. @click="closes2()"
  673. >确定</el-button
  674. >
  675. <el-table
  676. v-loading="tableDataLoading1"
  677. @selection-change="changeFun1"
  678. :data="userData.list"
  679. :row-key="
  680. row => {
  681. return row.userId;
  682. }
  683. "
  684. ref="multipleTable"
  685. >
  686. <el-table-column :reserve-selection="true" type="selection" fixed>
  687. </el-table-column>
  688. <el-table-column prop="userId" label="编号"> </el-table-column>
  689. <el-table-column fixed prop="nickName" label="昵称">
  690. <template slot-scope="scope">
  691. <span style="color: #f56c6c;">{{
  692. scope.row.nickName ? scope.row.nickName : "未设置"
  693. }}</span>
  694. </template>
  695. </el-table-column>
  696. <el-table-column label="图像">
  697. <template slot-scope="scope">
  698. <img
  699. v-if="scope.row.avatar == null"
  700. src="~@/assets/img/avatar.png"
  701. alt=""
  702. width="40"
  703. height="40"
  704. />
  705. <img v-else :src="scope.row.avatar" alt="" width="40" height="40" />
  706. </template>
  707. </el-table-column>
  708. <el-table-column prop="phone" label="手机号" width="120">
  709. <template slot-scope="scope">
  710. <span
  711. style="color: #4f9dec;cursor: pointer;"
  712. @click="updates(scope.row)"
  713. >{{ scope.row.phone ? scope.row.phone : "未绑定" }}</span
  714. >
  715. </template>
  716. </el-table-column>
  717. <el-table-column prop="platform" label="来源"> </el-table-column>
  718. <el-table-column prop="createTime" label="创建时间"> </el-table-column>
  719. </el-table>
  720. <div style="text-align: center;margin-top: 10px;">
  721. <el-pagination
  722. @size-change="handleSizeChange2"
  723. @current-change="handleCurrentChange2"
  724. :page-sizes="[5, 10, 15, 20]"
  725. :page-size="size1"
  726. :current-page="page1"
  727. layout="total,sizes, prev, pager, next,jumper"
  728. :total="userData.totalCount"
  729. >
  730. </el-pagination>
  731. </div>
  732. </el-dialog>
  733. <!-- 商户列表 -->
  734. <el-dialog
  735. title="商户列表"
  736. :visible.sync="dialogFormVisible11"
  737. center
  738. width="80%"
  739. >
  740. <el-input
  741. style="width: 150px;"
  742. @keydown.enter.native="select11"
  743. clearable
  744. placeholder="请输入商户名称"
  745. v-model="shopName1"
  746. >
  747. </el-input
  748. >&nbsp;&nbsp;&nbsp;&nbsp;
  749. <div style="display: inline-block;">
  750. <el-button
  751. style="margin-left:15px;"
  752. size="mini"
  753. type="primary"
  754. icon="document"
  755. @click="select11"
  756. >查询
  757. </el-button>
  758. <el-button
  759. style="margin-left:15px;"
  760. size="mini"
  761. type="primary"
  762. icon="document"
  763. @click="cleans11"
  764. >重置
  765. </el-button>
  766. </div>
  767. <el-table v-loading="tableDataLoading11" :data="shopData.list">
  768. <el-table-column label="编号" prop="shopId" width="80" fixed="left">
  769. </el-table-column>
  770. <el-table-column label="名称" prop="shopName" fixed="left">
  771. </el-table-column>
  772. <el-table-column label="店铺手机号" prop="phone" width="120">
  773. </el-table-column>
  774. <el-table-column label="商铺类型" prop="shopTypeName">
  775. </el-table-column>
  776. <el-table-column prop="shopCover" label="封面图" width="150">
  777. <template slot-scope="scope">
  778. <div style="display: inline-block; margin: 3px;">
  779. <el-popover placement="top-start" title="" trigger="hover">
  780. <img
  781. style="width: 50px; height: 50px"
  782. :src="scope.row.shopCover"
  783. alt=""
  784. slot="reference"
  785. />
  786. <img
  787. style="width: 300px; height: auto"
  788. :src="scope.row.shopCover"
  789. alt=""
  790. />
  791. </el-popover>
  792. </div>
  793. </template>
  794. </el-table-column>
  795. <el-table-column label="营业状态" prop="putawayFlag">
  796. <template slot-scope="scope">
  797. <span>{{ scope.row.putawayFlag == 0 ? "上班啦" : "打烊啦" }}</span>
  798. </template>
  799. </el-table-column>
  800. <el-table-column label="配送费" prop="errandMoney" width="150">
  801. <template slot-scope="scope">
  802. <span>{{ scope.row.errandMoney ? scope.row.errandMoney : 0 }}</span>
  803. <el-button
  804. size="mini"
  805. type="danger"
  806. style="color: #4f9dec;background: #fff;border: none;"
  807. :disabled="!isAuth('userList:updateMoney')"
  808. @click="rechargenone(scope.row, 1)"
  809. >修改配送费
  810. </el-button>
  811. </template>
  812. </el-table-column>
  813. <el-table-column
  814. label="配送距离"
  815. prop="distributionDistance"
  816. width="150"
  817. >
  818. <template slot-scope="scope">
  819. <span>{{
  820. scope.row.distributionDistance
  821. ? scope.row.distributionDistance
  822. : 0
  823. }}</span>
  824. </template>
  825. </el-table-column>
  826. <el-table-column label="商铺标签" prop="shopLable"> </el-table-column>
  827. <el-table-column label="开店时间" prop="businessHours">
  828. </el-table-column>
  829. <el-table-column label="闭店时间" prop="lockHours"> </el-table-column>
  830. <el-table-column label="商铺评分" prop="shopScore"> </el-table-column>
  831. <el-table-column label="商铺销量" prop="shopSales"> </el-table-column>
  832. <el-table-column label="商家公告" prop="shopNotice" width="150">
  833. </el-table-column>
  834. <el-table-column fixed="right" label="操作">
  835. <template slot-scope="scope">
  836. <el-button
  837. style="margin-left:15px;"
  838. size="mini"
  839. type="primary"
  840. icon="document"
  841. @click="closes3(scope.row)"
  842. >
  843. 确定</el-button
  844. >
  845. </template>
  846. </el-table-column>
  847. </el-table>
  848. <div style="text-align: center;margin-top: 10px;">
  849. <el-pagination
  850. @size-change="handleSizeChangeS"
  851. @current-change="handleCurrentChangeS"
  852. :page-sizes="[10, 20, 30, 50]"
  853. :page-size="size1"
  854. :current-page="page1"
  855. layout="total,sizes, prev, pager, next,jumper"
  856. :total="shopData.totalCount"
  857. >
  858. </el-pagination>
  859. </div>
  860. </el-dialog>
  861. </div>
  862. </template>
  863. <script>
  864. export default {
  865. data() {
  866. return {
  867. userId: "",
  868. superAdmin: "", // 判断是否为超级管理员 1是超级管理员 0不是超级管理员
  869. selectState: "",
  870. limit: 10,
  871. page: 1,
  872. size1: 10,
  873. page1: 1,
  874. checkBoxData: [], //多选框选择的值
  875. formLabelWidth: "200px",
  876. tableDataLoading: false,
  877. dialogFormVisible: false,
  878. dialogFormVisible1: false,
  879. dialogFormVisible0: false,
  880. dialogFormVisible5: false,
  881. tableDataLoading1: false,
  882. tableData: [],
  883. couponName: "",
  884. couponPicture: "",
  885. endDate: "",
  886. minMoney: "",
  887. money: "",
  888. needIntegral: "100",
  889. // 使用范围
  890. allMerchant: false,
  891. someMerchant: false,
  892. dataTree: [],
  893. defaultProps: {
  894. label: "shopName",
  895. value: "shopId"
  896. },
  897. merchantPage: 1,
  898. merchantLimit: 20,
  899. selectName: "",
  900. allShopListShow: false, // 商家下拉全部加载完成
  901. allShopLoading: true, // 商家下拉数据加载中
  902. merchantList: [],
  903. usedShopId: "",
  904. selectMerchant: [], // 勾选中的数据
  905. merchantTotalPage: 1,
  906. merchantSelectTotal: "",
  907. form: {
  908. couponId: "",
  909. couponName: "",
  910. couponPicture: "",
  911. endDate: "",
  912. minMoney: "",
  913. money: "",
  914. needIntegral: ""
  915. },
  916. userNameList: [],
  917. userIdList: [],
  918. userData: [],
  919. phone: "",
  920. nickName: "",
  921. couponId: "",
  922. activeName: "seventh",
  923. shopName: "",
  924. shopId: 0,
  925. tableDataLoading11: false,
  926. dialogFormVisible11: false,
  927. shopIds: "",
  928. shopNames: "",
  929. shopName1: "",
  930. shopData: {},
  931. shopIds2: "",
  932. content: "",
  933. couponLogVisible: false, // 查看优惠券日志
  934. couponLogLoading: false,
  935. couponLogTable: [],
  936. couponLogLimit: 10,
  937. couponLogPage: 1,
  938. couponLogTotal: 1
  939. };
  940. },
  941. methods: {
  942. handleClick(tab, event) {
  943. if (tab._props.label == "平台优惠券") {
  944. this.page = 1;
  945. this.limit = 10;
  946. this.shopName = "";
  947. this.shopId = 0;
  948. this.dataSelect();
  949. }
  950. if (tab._props.label == "商家优惠券") {
  951. this.page = 1;
  952. this.limit = 10;
  953. this.shopName = "";
  954. this.shopId = -1;
  955. this.dataSelect();
  956. }
  957. },
  958. // 多选
  959. changeFun(val) {
  960. this.checkBoxData = val;
  961. },
  962. handleSizeChange(val) {
  963. this.limit = val;
  964. this.dataSelect();
  965. },
  966. handleCurrentChange(val) {
  967. this.page = val;
  968. this.dataSelect();
  969. },
  970. handleSizeChange2(val) {
  971. this.size1 = val;
  972. this.dataSelect1();
  973. },
  974. handleCurrentChange2(val) {
  975. this.page1 = val;
  976. this.dataSelect1();
  977. },
  978. handleSizeChangeS(val) {
  979. this.size1 = val;
  980. this.dataSelect11();
  981. },
  982. handleCurrentChangeS(val) {
  983. this.page1 = val;
  984. this.dataSelect11();
  985. },
  986. beforeAvatarUpload(file) {
  987. return this.$processImage(this, file, false);
  988. },
  989. handleAvatarSuccess1(file, fileList) {
  990. this.couponPicture = file.data;
  991. },
  992. handleAvatarSuccess2(file, fileList) {
  993. this.form.couponPicture = file.data;
  994. },
  995. // 刷新
  996. refresh() {
  997. this.page = 1;
  998. this.dataSelect();
  999. },
  1000. // 查看优惠券日志
  1001. couponLog() {
  1002. this.couponLogVisible = true;
  1003. this.couponLogList();
  1004. },
  1005. couponLogList() {
  1006. this.couponLogLoading = true;
  1007. this.$http({
  1008. url: this.$http.adornUrl("admin/couponLog/selectCouponLog"),
  1009. method: "get",
  1010. params: this.$http.adornParams({
  1011. page: this.couponLogPage,
  1012. limit: this.couponLogLimit
  1013. })
  1014. }).then(({ data }) => {
  1015. console.log(data, "查看优惠券日志");
  1016. this.couponLogLoading = false;
  1017. let returnData = data.data;
  1018. this.couponLogTable = returnData.list;
  1019. this.couponLogTotal = returnData.totalCount;
  1020. });
  1021. },
  1022. couponLogSize(val) {
  1023. this.couponLogLimit = val;
  1024. this.couponLogList();
  1025. },
  1026. couponLogCurrent(val) {
  1027. this.couponLogPage = val;
  1028. this.couponLogList();
  1029. },
  1030. // 添加优惠券弹框
  1031. classifyStair() {
  1032. this.couponName = "";
  1033. this.couponPicture = "";
  1034. this.endDate = "";
  1035. this.minMoney = "";
  1036. this.money = "";
  1037. this.needIntegral = "100";
  1038. this.shopNames = "";
  1039. this.merchantPage = 1;
  1040. this.merchantList = [];
  1041. this.selectMerchant = [];
  1042. this.allMerchant = false;
  1043. this.someMerchant = false;
  1044. this.allShopListShow = false;
  1045. if (this.shopId === 0) {
  1046. this.shopIds = 0;
  1047. this.merchantData();
  1048. } else {
  1049. this.shopIds = "";
  1050. }
  1051. // 重置滚动位置
  1052. // this.$nextTick(() => {
  1053. // console.log(document.querySelector('.shop'));
  1054. // // document.querySelector('.el-tree__body-wrapper')
  1055. // const treeWrapper = this.$refs.tree;
  1056. // if (treeWrapper) {
  1057. // treeWrapper.scrollTop = 0; // 重置滚动位置
  1058. // }
  1059. // });
  1060. this.dialogFormVisible = true;
  1061. },
  1062. // 确定添加优惠券
  1063. StairNoticeTo() {
  1064. if (this.couponName == "") {
  1065. this.$notify({
  1066. title: "提示",
  1067. duration: 1800,
  1068. message: "请输入优惠券名称",
  1069. type: "warning"
  1070. });
  1071. return;
  1072. }
  1073. if (this.couponPicture == "") {
  1074. this.$notify({
  1075. title: "提示",
  1076. duration: 1800,
  1077. message: "请上传图片",
  1078. type: "warning"
  1079. });
  1080. return;
  1081. }
  1082. if (this.money == "") {
  1083. this.$notify({
  1084. title: "提示",
  1085. duration: 1800,
  1086. message: "请输入优惠券金额",
  1087. type: "warning"
  1088. });
  1089. return;
  1090. }
  1091. if (this.minMoney == "") {
  1092. this.$notify({
  1093. title: "提示",
  1094. duration: 1800,
  1095. message: "请输入最低消费",
  1096. type: "warning"
  1097. });
  1098. return;
  1099. }
  1100. if (this.endDate == "") {
  1101. this.$notify({
  1102. title: "提示",
  1103. duration: 1800,
  1104. message: "请输入有效天数",
  1105. type: "warning"
  1106. });
  1107. return;
  1108. }
  1109. if (this.shopId == 0) {
  1110. if (!this.allMerchant && !this.someMerchant) {
  1111. this.$notify({
  1112. title: "提示",
  1113. duration: 1800,
  1114. message: "商家不能为空",
  1115. type: "warning"
  1116. });
  1117. return;
  1118. }
  1119. }
  1120. if (this.shopId === 0) {
  1121. this.usedShopId = "";
  1122. if (this.allMerchant) {
  1123. this.usedShopId = 0;
  1124. }
  1125. if (this.someMerchant) {
  1126. this.usedShopId = this.selectMerchant.join(",");
  1127. }
  1128. if (this.needIntegral == "") {
  1129. this.$notify({
  1130. title: "提示",
  1131. duration: 1800,
  1132. message: "请输入兑换积分",
  1133. type: "warning"
  1134. });
  1135. return;
  1136. }
  1137. } else {
  1138. this.usedShopId = "";
  1139. }
  1140. this.$http({
  1141. url: this.$http.adornUrl("admin/coupon/issueCoupon"),
  1142. method: "post",
  1143. data: this.$http.adornData({
  1144. couponName: this.couponName,
  1145. couponPicture: this.couponPicture,
  1146. endDate: this.endDate,
  1147. minMoney: this.minMoney,
  1148. money: this.money,
  1149. needIntegral: this.needIntegral,
  1150. shopId: this.shopIds,
  1151. sysUserId: this.userId,
  1152. usedShopId: this.usedShopId
  1153. })
  1154. }).then(({ data }) => {
  1155. if (data.code == 0) {
  1156. this.dialogFormVisible = false;
  1157. this.$message({
  1158. message: "添加成功",
  1159. type: "success",
  1160. duration: 1500,
  1161. onClose: () => {
  1162. this.dataSelect();
  1163. }
  1164. });
  1165. } else {
  1166. this.$message({
  1167. message: data.msg,
  1168. type: "warning",
  1169. duration: 1500,
  1170. onClose: () => {}
  1171. });
  1172. }
  1173. });
  1174. },
  1175. checkChange(val, title) {
  1176. console.log(val, title);
  1177. if (val) {
  1178. if (title == "不限制") {
  1179. this.someMerchant = false;
  1180. }
  1181. if (title == "部分商家") {
  1182. this.allMerchant = false;
  1183. // this.merchantData();
  1184. }
  1185. }
  1186. this.$nextTick(() => {
  1187. if (this.$refs.tree) {
  1188. this.$refs.tree.setCheckedKeys(this.selectMerchant);
  1189. }
  1190. });
  1191. },
  1192. treeCheck(checkedNodes, checkedKeys) {
  1193. console.log(checkedKeys.checkedKeys);
  1194. this.selectMerchant = checkedKeys.checkedKeys;
  1195. },
  1196. // 平台优惠券 弹窗 搜索商铺
  1197. shopNameSeache() {
  1198. this.merchantPage = 1;
  1199. this.merchantData();
  1200. },
  1201. // 商铺列表
  1202. merchantData(title) {
  1203. this.allShopLoading = true;
  1204. this.$http({
  1205. url: this.$http.adornUrl("admin/goods/selectAllShop"),
  1206. method: "get",
  1207. params: this.$http.adornParams({
  1208. page: this.merchantPage,
  1209. limit: this.merchantLimit,
  1210. shopName: this.selectName
  1211. })
  1212. }).then(({ data }) => {
  1213. console.log(data, "店铺名称列表");
  1214. if (data.code == 0) {
  1215. if (title == "滚动") {
  1216. this.dataTree = [...this.dataTree, ...data.data.list];
  1217. } else {
  1218. this.dataTree = data.data.list;
  1219. }
  1220. console.log(this.selectMerchant, "选择的数据");
  1221. if (this.$refs.tree) {
  1222. this.$refs.tree.setCheckedKeys(this.selectMerchant);
  1223. }
  1224. this.merchantTotalPage = data.data.totalPage;
  1225. this.allShopLoading = false;
  1226. }
  1227. });
  1228. },
  1229. // 树形组件滚动操作
  1230. handleTreeScroll(event) {
  1231. const { scrollTop, scrollHeight, clientHeight } = event.target;
  1232. // 判断是否滚动到底部
  1233. if (scrollTop + clientHeight >= scrollHeight) {
  1234. console.log("滚动到底部了");
  1235. // 在这里执行你需要的逻辑,比如加载更多数据
  1236. if (this.merchantPage >= this.merchantTotalPage) {
  1237. // this.$message({
  1238. // title: "提示",
  1239. // duration: 1800,
  1240. // message: "数据已全部加载完",
  1241. // type: "warning"
  1242. // });
  1243. this.allShopListShow = true;
  1244. return;
  1245. }
  1246. this.merchantPage++;
  1247. console.log(this.merchantPage, "后");
  1248. this.merchantData("滚动");
  1249. }
  1250. },
  1251. // 修改优惠券
  1252. compile(index, rows) {
  1253. this.selectMerchant = [];
  1254. console.log(rows);
  1255. this.merchantPage = 1;
  1256. this.merchantData();
  1257. if (rows.usedShopId == 0) {
  1258. this.usedShopId = 0;
  1259. this.allMerchant = true;
  1260. this.someMerchant = false;
  1261. } else if (rows.usedShopId != null && rows.usedShopId != 0) {
  1262. this.usedShopId = rows.usedShopId;
  1263. this.selectMerchant = rows.usedShopId.split(",");
  1264. this.allMerchant = false;
  1265. this.someMerchant = true;
  1266. } else {
  1267. this.usedShopId = "";
  1268. this.allMerchant = false;
  1269. this.someMerchant = false;
  1270. }
  1271. this.allShopListShow = false;
  1272. this.form.couponName = rows.couponName;
  1273. this.form.couponPicture = rows.couponPicture;
  1274. this.form.endDate = rows.endDate;
  1275. this.form.minMoney = rows.minMoney;
  1276. this.form.money = rows.money;
  1277. this.form.needIntegral = rows.needIntegral;
  1278. this.form.couponId = rows.couponId;
  1279. this.shopNames = rows.shopName;
  1280. this.shopIds = rows.shopId;
  1281. this.dialogFormVisible1 = true;
  1282. },
  1283. compileClose() {
  1284. if (this.shopId == 0 && this.someMerchant) {
  1285. this.$nextTick(() => {
  1286. const treeWrapper = this.$refs.tree.$el.querySelector(".el-tree");
  1287. if (treeWrapper) {
  1288. treeWrapper.scrollTop = 0;
  1289. }
  1290. });
  1291. }
  1292. this.dialogFormVisible1 = false;
  1293. this.allMerchant = false;
  1294. this.someMerchant = false;
  1295. },
  1296. // 确定修改优惠券
  1297. CompileNoticeTo() {
  1298. if (this.form.campusName == "") {
  1299. this.$notify({
  1300. title: "提示",
  1301. duration: 1800,
  1302. message: "请输入优惠券名称",
  1303. type: "warning"
  1304. });
  1305. return;
  1306. }
  1307. if (this.form.couponPicture == "") {
  1308. this.$notify({
  1309. title: "提示",
  1310. duration: 1800,
  1311. message: "请上传图片",
  1312. type: "warning"
  1313. });
  1314. return;
  1315. }
  1316. if (this.form.money == "") {
  1317. this.$notify({
  1318. title: "提示",
  1319. duration: 1800,
  1320. message: "请输入优惠券金额",
  1321. type: "warning"
  1322. });
  1323. return;
  1324. }
  1325. if (this.form.minMoney == "") {
  1326. this.$notify({
  1327. title: "提示",
  1328. duration: 1800,
  1329. message: "请输入最低消费",
  1330. type: "warning"
  1331. });
  1332. return;
  1333. }
  1334. if (this.form.endDate == "") {
  1335. this.$notify({
  1336. title: "提示",
  1337. duration: 1800,
  1338. message: "请输入有效天数",
  1339. type: "warning"
  1340. });
  1341. return;
  1342. }
  1343. if (this.shopId == 0) {
  1344. if (!this.allMerchant && !this.someMerchant) {
  1345. this.$notify({
  1346. title: "提示",
  1347. duration: 1800,
  1348. message: "商家不能为空",
  1349. type: "warning"
  1350. });
  1351. return;
  1352. }
  1353. }
  1354. if (this.shopId === 0) {
  1355. this.usedShopId = "";
  1356. if (this.allMerchant) {
  1357. this.usedShopId = 0;
  1358. }
  1359. if (this.someMerchant) {
  1360. this.usedShopId = this.selectMerchant.join(",");
  1361. }
  1362. if (this.needIntegral == "") {
  1363. this.$notify({
  1364. title: "提示",
  1365. duration: 1800,
  1366. message: "请输入兑换积分",
  1367. type: "warning"
  1368. });
  1369. return;
  1370. }
  1371. } else {
  1372. this.usedShopId = "";
  1373. }
  1374. this.$http({
  1375. url: this.$http.adornUrl("admin/coupon/updateCoupon"),
  1376. method: "post",
  1377. data: this.$http.adornData({
  1378. couponId: this.form.couponId,
  1379. couponName: this.form.couponName,
  1380. couponPicture: this.form.couponPicture,
  1381. endDate: this.form.endDate,
  1382. minMoney: this.form.minMoney,
  1383. money: this.form.money,
  1384. needIntegral: this.form.needIntegral,
  1385. shopId: this.shopIds,
  1386. sysUserId: this.userId,
  1387. usedShopId: this.usedShopId
  1388. })
  1389. }).then(({ data }) => {
  1390. if (data.code == 0) {
  1391. this.$message({
  1392. message: "操作成功",
  1393. type: "success",
  1394. duration: 1500,
  1395. onClose: () => {
  1396. this.dialogFormVisible1 = false;
  1397. this.dataSelect();
  1398. }
  1399. });
  1400. } else {
  1401. this.$message({
  1402. message: data.msg,
  1403. type: "error",
  1404. duration: 1500,
  1405. onClose: () => {
  1406. this.dialogFormVisible1 = false;
  1407. this.dataSelect();
  1408. }
  1409. });
  1410. }
  1411. });
  1412. },
  1413. // 发布审核优惠券
  1414. announceStair(rows, index) {
  1415. let title = "";
  1416. if (index == 1) {
  1417. title = "确定发布此条优惠券?";
  1418. } else if (title == 2) {
  1419. title = "确定撤销此条优惠券?";
  1420. }
  1421. this.$confirm(`${title}`, "提示", {
  1422. confirmButtonText: "确定",
  1423. cancelButtonText: "取消",
  1424. type: "warning"
  1425. })
  1426. .then(() => {
  1427. this.$http({
  1428. url: this.$http.adornUrl("admin/coupon/checkCoupon"),
  1429. method: "get",
  1430. params: this.$http.adornParams({
  1431. couponId: rows.couponId,
  1432. sysUserId: this.userId,
  1433. state: index
  1434. })
  1435. }).then(({ data }) => {
  1436. console.log(data);
  1437. if (data.code == 0) {
  1438. this.$message({
  1439. message: "操作成功",
  1440. type: "success",
  1441. duration: 1500,
  1442. onClose: () => {
  1443. this.dataSelect();
  1444. }
  1445. });
  1446. } else {
  1447. this.$message({
  1448. message: data.msg,
  1449. type: "error",
  1450. duration: 1500,
  1451. onClose: () => {
  1452. this.dataSelect();
  1453. }
  1454. });
  1455. }
  1456. });
  1457. })
  1458. .catch(() => {});
  1459. },
  1460. // 删除
  1461. deleteStair(row) {
  1462. this.$confirm(`确定删除此条信息?`, "提示", {
  1463. confirmButtonText: "确定",
  1464. cancelButtonText: "取消",
  1465. type: "warning"
  1466. })
  1467. .then(() => {
  1468. this.$http({
  1469. url: this.$http.adornUrl("admin/coupon/deleteCoupon"),
  1470. method: "post",
  1471. params: this.$http.adornParams({
  1472. couponId: row.couponId,
  1473. sysUserId: this.userId
  1474. })
  1475. }).then(({ data }) => {
  1476. if (data.code == 0) {
  1477. this.$message({
  1478. message: "删除成功",
  1479. type: "success",
  1480. duration: 1500,
  1481. onClose: () => {
  1482. this.dataSelect();
  1483. }
  1484. });
  1485. } else {
  1486. this.$message({
  1487. message: data.msg,
  1488. type: "error",
  1489. duration: 1500,
  1490. onClose: () => {
  1491. this.dataSelect();
  1492. }
  1493. });
  1494. }
  1495. });
  1496. })
  1497. .catch(() => {});
  1498. },
  1499. // 重置
  1500. cleans() {
  1501. this.phone = "";
  1502. this.status = 0;
  1503. this.dataSelect();
  1504. },
  1505. // 获取派单数据列表
  1506. dataSelect() {
  1507. this.tableDataLoading = true;
  1508. if (this.shopId == 0) {
  1509. this.$http({
  1510. url: this.$http.adornUrl("admin/coupon/selectAdminCoupon"),
  1511. method: "get",
  1512. params: this.$http.adornParams({
  1513. page: this.page,
  1514. limit: this.limit,
  1515. state: this.selectState
  1516. })
  1517. }).then(({ data }) => {
  1518. console.log(data, "平台优惠券");
  1519. this.tableDataLoading = false;
  1520. let returnData = data.data;
  1521. this.tableData = returnData;
  1522. // if(data.data.list.length==0){
  1523. // this.page = this.page-1
  1524. // this.dataSelect()
  1525. // }
  1526. });
  1527. } else if (this.shopId == -1) {
  1528. this.$http({
  1529. url: this.$http.adornUrl("admin/coupon/seleteAllCoupon"),
  1530. method: "get",
  1531. params: this.$http.adornParams({
  1532. page: this.page,
  1533. limit: this.limit,
  1534. content: this.content,
  1535. shopId: this.shopId,
  1536. shopName: this.shopName
  1537. })
  1538. }).then(({ data }) => {
  1539. console.log(data, "商家优惠券");
  1540. this.tableDataLoading = false;
  1541. let returnData = data.data;
  1542. this.tableData = returnData;
  1543. // if(data.data.list.length==0){
  1544. // this.page = this.page-1
  1545. // this.dataSelect()
  1546. // }
  1547. });
  1548. }
  1549. },
  1550. // 赠送优惠券
  1551. songCoupon(row) {
  1552. this.couponId = row.couponId;
  1553. this.shopIds2 = row.shopId;
  1554. this.userIdList = [];
  1555. this.userNameList = [];
  1556. this.dialogFormVisible0 = true;
  1557. },
  1558. // 打开用户列表
  1559. couponIdBtn1() {
  1560. this.page1 = 1;
  1561. this.dataSelect1();
  1562. this.dialogFormVisible5 = true;
  1563. if (this.userIdList.length == 0) {
  1564. this.cleansHc();
  1565. }
  1566. },
  1567. // 清空选中缓存
  1568. cleansHc(rows) {
  1569. console.log("---", this.$refs.multipleTable);
  1570. if (this.$refs.multipleTable) {
  1571. this.$refs.multipleTable.clearSelection();
  1572. }
  1573. },
  1574. // 多选用户
  1575. changeFun1(val) {
  1576. console.log("多选", val);
  1577. var userIdList = [];
  1578. var userNameList = [];
  1579. for (var i in val) {
  1580. userIdList.push(val[i].userId);
  1581. userNameList.push(val[i].nickName);
  1582. }
  1583. this.userIdList = userIdList;
  1584. this.userNameList = userNameList;
  1585. console.log(JSON.stringify(this.userIdList));
  1586. },
  1587. // 赠送优惠券
  1588. songNoticeTo() {
  1589. if (this.userIdList.length == 0) {
  1590. this.$notify({
  1591. title: "提示",
  1592. duration: 1800,
  1593. message: "请选择用户",
  1594. type: "warning"
  1595. });
  1596. return;
  1597. }
  1598. if (this.shopId == -1) {
  1599. var shopIds1 = this.shopIds2;
  1600. } else {
  1601. var shopIds1 = this.shopId;
  1602. }
  1603. var userIdList = this.userIdList.toString();
  1604. this.$http({
  1605. url: this.$http.adornUrl("admin/coupon/giveCoupon"),
  1606. method: "get",
  1607. params: this.$http.adornParams({
  1608. userIds: userIdList,
  1609. shopId: shopIds1,
  1610. couponId: this.couponId
  1611. })
  1612. }).then(({ data }) => {
  1613. this.$message({
  1614. message: "操作成功",
  1615. type: "success",
  1616. duration: 1500,
  1617. onClose: () => {
  1618. this.userIdList = [];
  1619. this.userNameList = [];
  1620. this.shopIds2 = "";
  1621. this.dataSelect();
  1622. }
  1623. });
  1624. this.dialogFormVisible0 = false;
  1625. });
  1626. },
  1627. // 获取用户数据列表
  1628. dataSelect1() {
  1629. let phone = -1;
  1630. if (this.phone) {
  1631. phone = this.phone;
  1632. }
  1633. this.tableDataLoading1 = true;
  1634. this.$http({
  1635. url: this.$http.adornUrl("user/selectUserList"),
  1636. method: "get",
  1637. params: this.$http.adornParams({
  1638. page: this.page1,
  1639. limit: this.size1,
  1640. shopAdminFlag: "",
  1641. phone: this.phone,
  1642. userName: this.nickName,
  1643. type: ""
  1644. })
  1645. }).then(({ data }) => {
  1646. this.tableDataLoading1 = false;
  1647. let returnData = data.data;
  1648. this.userData = returnData;
  1649. });
  1650. },
  1651. // 查询
  1652. select1() {
  1653. this.page = 1;
  1654. this.dataSelect1();
  1655. },
  1656. // 重置
  1657. cleans1() {
  1658. this.page = 1;
  1659. this.phone = "";
  1660. this.nickName = "";
  1661. this.dataSelect1();
  1662. },
  1663. couponIdClose1(ietm, index) {
  1664. console.log("index", index, "ietm", ietm, this.userIdList.length);
  1665. if (this.userIdList.length < 2) {
  1666. this.$message({
  1667. title: "提示",
  1668. type: "error",
  1669. duration: 1800,
  1670. message: "最少需要选中一位用户",
  1671. type: "warning"
  1672. });
  1673. return;
  1674. } else {
  1675. this.userIdList.splice(index, 1);
  1676. this.userNameList.splice(index, 1);
  1677. }
  1678. },
  1679. // 批量开启
  1680. closes2(id) {
  1681. this.isCoupon = 1;
  1682. this.dialogFormVisible5 = false;
  1683. },
  1684. // 获取派单数据列表
  1685. dataSelectShop() {
  1686. this.tableDataLoading = true;
  1687. this.$http({
  1688. url: this.$http.adornUrl("coupon/seleteAllCoupon"),
  1689. method: "get",
  1690. params: this.$http.adornParams({
  1691. page: this.page,
  1692. limit: this.limit,
  1693. shopName: this.shopName,
  1694. shopId: this.shopId
  1695. })
  1696. }).then(({ data }) => {
  1697. this.tableDataLoading = false;
  1698. let returnData = data.data;
  1699. this.tableData = returnData;
  1700. // if(data.data.list.length==0){
  1701. // this.page = this.page-1
  1702. // this.dataSelect()
  1703. // }
  1704. });
  1705. },
  1706. // 获取用户数据列表
  1707. dataSelect11() {
  1708. this.tableDataLoading = true;
  1709. this.$http({
  1710. url: this.$http.adornUrl("admin/goods/selectAllShop"),
  1711. method: "get",
  1712. params: this.$http.adornParams({
  1713. page: this.page1,
  1714. limit: this.size1,
  1715. shopName: this.shopName1,
  1716. region: "",
  1717. isActivity: ""
  1718. })
  1719. }).then(({ data }) => {
  1720. this.tableDataLoading = false;
  1721. for (var i in data.data.list) {
  1722. if (data.data.list[i].shopBanner) {
  1723. data.data.list[i].shopBanner = data.data.list[i].shopBanner.split(
  1724. ","
  1725. );
  1726. }
  1727. }
  1728. let returnData = data.data;
  1729. this.shopData = returnData;
  1730. });
  1731. },
  1732. // 查询
  1733. select11() {
  1734. this.page1 = 1;
  1735. this.dataSelect11();
  1736. },
  1737. // 查看用户
  1738. selectUserId() {
  1739. this.dialogFormVisible11 = true;
  1740. this.page1 = 1;
  1741. this.shopName1 = "";
  1742. this.dataSelect11();
  1743. },
  1744. // 重置
  1745. cleans11() {
  1746. this.page1 = 1;
  1747. this.shopName1 = "";
  1748. this.dataSelect11();
  1749. },
  1750. closes3(row) {
  1751. this.shopIds = row.shopId;
  1752. this.shopNames = row.shopName;
  1753. this.dialogFormVisible11 = false;
  1754. },
  1755. refreshShop() {
  1756. this.page = 1;
  1757. this.dataSelect();
  1758. }
  1759. },
  1760. mounted() {
  1761. this.dataSelect();
  1762. },
  1763. created() {
  1764. var userId = this.$cookie.get("userId");
  1765. this.userId = userId;
  1766. this.$http({
  1767. url: this.$http.adornUrl("sys/user/isSuperAdmin"),
  1768. method: "get",
  1769. params: this.$http.adornParams({
  1770. sysUserId: userId
  1771. })
  1772. }).then(({ data }) => {
  1773. console.log(data);
  1774. if (data.code == 0) {
  1775. this.superAdmin = data.superAdmin;
  1776. } else {
  1777. this.$message({
  1778. message: data.msg,
  1779. type: "warning",
  1780. duration: 1500,
  1781. onClose: () => {}
  1782. });
  1783. }
  1784. });
  1785. // 超级管理员 审核中 发布 撤销
  1786. // 已发布 赠送 编辑 删除
  1787. // 已撤销
  1788. // 普通用户 审核中
  1789. // 已发布 赠送 删除
  1790. // 已撤销
  1791. }
  1792. };
  1793. </script>
  1794. <style lang="scss">
  1795. .couponLog {
  1796. width: 60%;
  1797. }
  1798. .discount {
  1799. width: 1000px;
  1800. .shop {
  1801. .el-tree-node__content {
  1802. .is-leaf.el-tree-node__expand-icon {
  1803. // display: none;
  1804. }
  1805. }
  1806. }
  1807. }
  1808. </style>