index.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <div id="app" v-cloak>
  2. <el-card shadow="never" style="border:0;min-width: 800px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  3. <div slot="header">
  4. <span>商城列表</span>
  5. </div>
  6. <div class="table-body">
  7. <el-form size="small" :inline="true" v-if="is_master">
  8. <el-form-item>
  9. <el-input style="width: 200px" v-model="searchData.keyword" placeholder="商城名称/ID" clearable></el-input>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-input style="width: 200px" v-model="searchData.min_balance" placeholder="资金低于" clearable>
  13. <template #append>元</template>
  14. </el-input>
  15. </el-form-item>
  16. <el-form-item>
  17. <el-button type="primary" @click="searchs">搜索</el-button>
  18. </el-form-item>
  19. </el-form>
  20. <el-tabs v-model="activeName" @tab-click="handleClick">
  21. <el-table :data="list" stripe v-loading="loading" size="small" style="margin-bottom: 15px;">
  22. <el-table-column prop="id" label="商城ID" width="200" align="center"></el-table-column>
  23. <el-table-column label="商城信息">
  24. <template slot-scope="scope">
  25. <div class="table-info-img-text">
  26. <el-image class="table-info-img circle" :src="scope.row.logo">
  27. <div slot="error" class="image-slot">
  28. <com-image src="/resources/img/admin/mall-logo.png"></com-image>
  29. </div>
  30. </el-image>
  31. <div class="table-info-text">
  32. <div style="color:#000;">{{scope.row.name}}</div>
  33. </div>
  34. </div>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="余额" align="center">
  38. <template slot-scope="scope">
  39. <div :style="scope.row.balance * 0.01 <= config.min_balance ? 'color: red' : ''">{{scope.row.balance|amount}}</div>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="定价策略" align="left" v-if="is_master">
  43. <template slot-scope="scope">
  44. <div flex="cross:center" v-if="is_master">
  45. <div v-if="rate_id != scope.row.id" flex="cross:center">
  46. <el-tooltip class="item" effect="dark" :content="scope.row.rate+''" placement="top">
  47. <span class="over2">{{scope.row.rate|amount}}%</span>
  48. </el-tooltip>
  49. <el-button class="edit-sort" type="text" @click="edit(scope.row,'rate')">
  50. <img src="resources/img/mall/order/edit.png" alt="">
  51. </el-button>
  52. </div>
  53. <div style="display: flex;align-items: center" v-else>
  54. <el-input style="min-width: 70px" size="mini" class="change" v-model="rate" autocomplete="off"></el-input>
  55. <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px" icon="el-icon-error" circle @click="cancelEdit('rate')"></el-button>
  56. <el-button class="change-success" type="text" style="margin-left: 0;color: #67C23A;padding: 0 5px" icon="el-icon-success" circle @click="handle('rate',scope.row)">
  57. </el-button>
  58. </div>
  59. </div>
  60. <div v-else>
  61. <span class="over2">{{scope.row.rate|amount}}%</span>
  62. </div>
  63. </template>
  64. </el-table-column>
  65. <!-- <el-table-column label="企商通定价策略" align="center">-->
  66. <!-- <template slot-scope="scope">-->
  67. <!-- <div flex="cross:center">-->
  68. <!-- <div v-if="shang_rate_id != scope.row.id" flex="cross:center">-->
  69. <!-- <el-tooltip class="item" effect="dark" :content="scope.row.shang_rate+''" placement="top">-->
  70. <!-- <span class="over2">{{scope.row.shang_rate|amount}}%</span>-->
  71. <!-- </el-tooltip>-->
  72. <!-- <el-button class="edit-sort" type="text" @click="edit(scope.row,'shang_rate')">-->
  73. <!-- <img src="resources/img/mall/order/edit.png" alt="">-->
  74. <!-- </el-button>-->
  75. <!-- </div>-->
  76. <!-- <div style="display: flex;align-items: center" v-else>-->
  77. <!-- <el-input style="min-width: 70px" size="mini" class="change" v-model="shang_rate" autocomplete="off"></el-input>-->
  78. <!-- <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px" icon="el-icon-error" circle @click="cancelEdit('shang_rate')"></el-button>-->
  79. <!-- <el-button class="change-success" type="text" style="margin-left: 0;color: #67C23A;padding: 0 5px" icon="el-icon-success" circle @click="handle('shang_rate',scope.row)">-->
  80. <!-- </el-button>-->
  81. <!-- </div>-->
  82. <!-- </div>-->
  83. <!-- </template>-->
  84. <!-- </el-table-column>-->
  85. <el-table-column label="创建时间" align="center">
  86. <template slot-scope="scope">
  87. <div>{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="操作" align="center">
  91. <template slot-scope="scope">
  92. <el-popconfirm v-if="is_master" @confirm="onRecharge(scope.row)" title="您真的要对当前商城进行余额操作吗?">
  93. <el-button type="text" slot="reference" style="color: #F56C6C">余额充值</el-button>
  94. </el-popconfirm>
  95. <div v-else>-</div>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. </el-tabs>
  100. <div flex="box:last cross:center">
  101. <div></div>
  102. <div>
  103. <el-pagination v-if="list && list.length > 0" style="display: inline-block;" background :page-size="pagination.pageSize" @current-change="pageChange" layout="prev, pager, next" :current-page="pagination.current_page" :total="pagination.totalCount">
  104. </el-pagination>
  105. </div>
  106. </div>
  107. </div>
  108. </el-card>
  109. <el-dialog
  110. title="余额充值"
  111. :visible.sync="dialogVisible"
  112. width="50%">
  113. <el-form :model="ruleForm" size="small" ref="ruleForm" label-width="300px">
  114. <el-form-item label="充值金额" prop="amount" :rules="[{required: true, message:'请输入充值金额'}]">
  115. <el-input v-model="ruleForm.amount" placeholder="请输入充值金额">
  116. <template #append>元</template>
  117. </el-input>
  118. <p style="color: #999999">如果小于0则为扣除金额</p>
  119. </el-form-item>
  120. <el-form-item label="操作备注" prop="remark" :rules="[{required: true, message:'请输入操作备注'}]">
  121. <el-input type="textarea" :rows="3" v-model="ruleForm.remark" placeholder="请输入操作备注">
  122. </el-input>
  123. </el-form-item>
  124. </el-form>
  125. <span slot="footer" class="dialog-footer">
  126. <el-button @click="dialogVisible = false">取 消</el-button>
  127. <el-button :disabled="btnLoading" v-loading="btnLoading" type="primary" @click="onSubmit">确 定</el-button>
  128. </span>
  129. </el-dialog>
  130. </div>
  131. <script>
  132. const app = new Vue({
  133. el: '#app',
  134. data: {
  135. searchData: {
  136. keyword: '',
  137. min_balance: '',
  138. page: 1,
  139. limit: 10,
  140. },
  141. loading: false,
  142. activeName: '-1',
  143. list: [],
  144. pagination: null,
  145. currentItem: null,
  146. ruleForm: {
  147. mall_id: 0,
  148. amount: 0,
  149. remark: ''
  150. },
  151. dialogVisible: false,
  152. btnLoading: false,
  153. config: {
  154. min_balance: 0
  155. },
  156. rate: 0,
  157. rate_id: 0,
  158. shang_rate: 0,
  159. shang_rate_id: 0,
  160. is_master: <?= $is_master ? 1 : 0 ?>,
  161. },
  162. mounted() {
  163. this.loadData();
  164. },
  165. methods: {
  166. confirmSubmit() {
  167. this.search.status = this.activeName
  168. },
  169. selectDateTime(e) {
  170. if (e != null) {
  171. this.searchData.start_date = e[0];
  172. this.searchData.end_date = e[1];
  173. } else {
  174. this.searchData.start_date = '';
  175. this.searchData.end_date = '';
  176. }
  177. this.searchs();
  178. },
  179. loadData() {
  180. this.loading = true;
  181. request({
  182. params: {
  183. r: 'qi-ding-dong/mall/index',
  184. ...this.searchData
  185. },
  186. }).then(e => {
  187. this.loading = false;
  188. if (e.data.code === 0) {
  189. this.list = e.data.data.list
  190. this.pagination = e.data.data.pagination;
  191. this.config = Object.assign(this.config, e.data.data.config)
  192. } else {
  193. this.$message.error(e.data.msg);
  194. }
  195. }).catch(e => {
  196. this.loading = false;
  197. });
  198. },
  199. pageChange(page) {
  200. this.searchData.page = page;
  201. this.loadData();
  202. },
  203. handleClick(tab, event) {},
  204. searchs() {
  205. this.searchData.page = 1;
  206. this.loadData();
  207. },
  208. onRecharge(item) {
  209. this.currentItem = item
  210. this.ruleForm.mall_id = item.id
  211. this.dialogVisible = true
  212. },
  213. onSubmit() {
  214. this.$refs['ruleForm'].validate((valid) => {
  215. if (valid) {
  216. this.btnLoading = true;
  217. request({
  218. params: {
  219. r: 'qi-ding-dong/mall/recharge',
  220. },
  221. method: 'post',
  222. data: this.ruleForm
  223. }).then(e => {
  224. this.btnLoading = false;
  225. if (e.data.code == 0) {
  226. this.$message.success(e.data.msg);
  227. this.loadData()
  228. this.dialogVisible = false
  229. } else {
  230. this.$message.error(e.data.msg);
  231. }
  232. }).catch(e => {
  233. this.$message.error(e);
  234. this.btnLoading = false;
  235. })
  236. }
  237. })
  238. },
  239. cancelEdit(type) {
  240. switch (type) {
  241. case 'shang_rate':
  242. this.shang_rate = 0;
  243. this.shang_rate_id = 0;
  244. break;
  245. case 'rate':
  246. this.rate = 0;
  247. this.rate_id = 0;
  248. break;
  249. }
  250. },
  251. edit(row, type) {
  252. switch (type) {
  253. case 'shang_rate':
  254. this.shang_rate_id = row.id;
  255. this.shang_rate = row.shang_rate;
  256. break;
  257. case 'rate':
  258. this.rate_id = row.id;
  259. this.rate = parseFloat(row.rate * 0.01).toFixed(2);
  260. break;
  261. }
  262. },
  263. handle(type, data = null) {
  264. let id = null
  265. let val = null
  266. let field = type
  267. switch (type) {
  268. case 'rate':
  269. id = this.rate_id
  270. val = this.rate
  271. break
  272. case 'shang_rate':
  273. id = this.shang_rate_id
  274. val = this.shang_rate
  275. break
  276. }
  277. request({
  278. params: {
  279. r: 'qi-ding-dong/mall/rate',
  280. },
  281. method: 'post',
  282. data: {
  283. mall_id: id,
  284. field: field,
  285. val: val,
  286. }
  287. }).then(e => {
  288. this.btnLoading = false;
  289. if (e.data.code == 0) {
  290. this.$message.success(e.data.msg);
  291. this.loadData()
  292. this.cancelEdit(type)
  293. } else {
  294. this.$message.error(e.data.msg);
  295. }
  296. }).catch(e => {
  297. this.$message.error(e);
  298. this.btnLoading = false;
  299. })
  300. }
  301. },
  302. filters: {
  303. amount: function(val) {
  304. return parseFloat(val * 0.01).toFixed(2)
  305. }
  306. }
  307. });
  308. </script>
  309. <style>
  310. .el-tabs__header {
  311. font-size: 16px;
  312. }
  313. .table-body {
  314. padding: 20px;
  315. background-color: #fff;
  316. }
  317. .input-item {
  318. width: 250px;
  319. margin: 0 0 20px;
  320. display: inline-block;
  321. }
  322. .input-item .el-input__inner {
  323. border-right: 0;
  324. }
  325. .input-item .el-input__inner:hover {
  326. border: 1px solid #dcdfe6;
  327. border-right: 0;
  328. outline: 0;
  329. }
  330. .input-item .el-input__inner:focus {
  331. border: 1px solid #dcdfe6;
  332. border-right: 0;
  333. outline: 0;
  334. }
  335. .input-item .el-input-group__append {
  336. background-color: #fff;
  337. border-left: 0;
  338. width: 10%;
  339. padding: 0;
  340. }
  341. /* .input-item .el-input-group__append .el-button {
  342. padding: 0;
  343. }
  344. .input-item .el-input-group__append .el-button {
  345. margin: 0;
  346. } */
  347. .batch {
  348. margin: 0 0 20px;
  349. display: inline-block;
  350. }
  351. /* .batch .el-button {
  352. padding: 9px 15px !important;
  353. } */
  354. .el-table th>.cell {
  355. color: #333;
  356. font-weight: bold;
  357. font-size: 14px;
  358. }
  359. .el-table__footer-wrapper,
  360. .el-table__header-wrapper {
  361. border-bottom: 1.4px solid #D6D6D6;
  362. }
  363. </style>