synchronize.blade.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. @extends('layouts.base')
  2. @section('title', "默认值同步")
  3. @section('content')
  4. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}"/>
  5. <style>
  6. </style>
  7. <div class="all">
  8. <div id="app" v-cloak>
  9. <div class="vue-head">
  10. <div class="vue-main-title" style="margin-bottom:20px">
  11. <div class="vue-main-title-left"></div>
  12. <div class="vue-main-title-content">条件筛选</div>
  13. <div class="vue-main-title-button">
  14. </div>
  15. </div>
  16. <div class="vue-search">
  17. <el-form :inline="true" :model="search_form" ref="search_form" style="margin-left:10px;">
  18. <el-row>
  19. <el-form-item label="" prop="同步方式">
  20. <el-select v-model="search_form.update_type" placeholder="同步方式" clearable>
  21. <el-option label="商品类型" value="1"></el-option>
  22. <el-option label="指定商品" value="3"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="时间">
  26. <el-date-picker
  27. v-model="times"
  28. type="datetimerange"
  29. value-format="yyyy-MM-dd HH:mm:ss"
  30. range-separator="至"
  31. start-placeholder="开始日期"
  32. end-placeholder="结束日期"
  33. style="margin-left:5px;"
  34. align="right">
  35. </el-date-picker>
  36. </el-form-item>
  37. <el-form-item>
  38. <el-button type="primary" icon="el-icon-search" @click="search(1)">搜索
  39. </el-button>
  40. </el-form-item>
  41. </el-col>
  42. </el-row>
  43. </el-form>
  44. </div>
  45. </div>
  46. <div class="vue-main">
  47. <div class="vue-main-form">
  48. <div class="vue-main-title" style="margin-bottom:20px">
  49. <div class="vue-main-title-left"></div>
  50. <div class="vue-main-title-content" style="flex:0 0 120px">同步记录列表</div>
  51. <div class="vue-main-title-button">
  52. <el-button type="primary" plain icon="el-icon-refresh" size="small" @click="synchronizePopup(1)">分批同步</el-button>
  53. <el-button type="primary" plain icon="el-icon-refresh" size="small" @click="synchronizePopup(3)">一键同步</el-button>
  54. </div>
  55. </div>
  56. <el-table :data="list" style="width: 100%" v-loading="table_loading">
  57. <el-table-column prop="created_at" label="时间" align="center"></el-table-column>
  58. <el-table-column prop="way_name" label="同步方式" align="center"></el-table-column>
  59. <el-table-column prop="way_where" label="条件" align="center"></el-table-column>
  60. <el-table-column prop="total" label="同步总条数" align="center"></el-table-column>
  61. <el-table-column prop="success_num" label="成功条数" align="center"></el-table-column>
  62. <el-table-column prop="status_name" label="状态" align="center"></el-table-column>
  63. </el-table>
  64. </div>
  65. </div>
  66. <!-- 分页 -->
  67. <div class="vue-page" v-if="total>0">
  68. <el-row>
  69. <el-col align="right">
  70. <el-pagination layout="prev, pager, next,jumper" @current-change="search" :total="total"
  71. :page-size="per_page" :current-page="current_page" background
  72. ></el-pagination>
  73. </el-col>
  74. </el-row>
  75. </div>
  76. {{--一键同步--}}
  77. <el-dialog :visible.sync="batch_synchronize_goods" width="700px" center title="商品同步默认值"
  78. v-loading="synchronize_loading"
  79. element-loading-text="拼命同步中..."
  80. element-loading-spinner="el-icon-loading"
  81. element-loading-background="rgba(0, 0, 0, 0.8)"
  82. >
  83. <div style="height:300px;overflow:auto" id="dispatch-info">
  84. <el-form :model="synchronize_where" :rules="rules" ref="synchronize_where" label-width="20%">
  85. <el-form-item label-width="26%" label="插件商品类型">
  86. <el-form-item label="" prop="">
  87. <el-select v-model="synchronize_where.plugin_type" placeholder="请选择商品类型" clearable>
  88. <el-option v-for="item in plugin_type_list" :key="item.code" :label="item.name"
  89. :value="item.plugin_id"></el-option>
  90. </el-select>
  91. <el-button type="primary" v-loading="paginate_loading" icon="el-icon-search" @click="goodsPaginate()">查询数量</el-button>
  92. <div style="font-size:12px;">请在服务器负担较小是同步,先统计商品数再选择分批同步,每页最多1000条商品</div>
  93. </el-form-item>
  94. <el-form-item label="" prop="" label="每页数量" >
  95. <el-input v-model="synchronize_where.goods_per_page" placeholder="每页数量"></el-input>
  96. </el-form-item>
  97. </el-form-item>
  98. <el-form-item v-if="goods_total > 0" label="分页同步">
  99. <el-pagination
  100. background
  101. layout="prev, pager, next"
  102. @current-change="switchPage"
  103. :page-size="goods_per_page"
  104. :current-page="goods_current_page"
  105. :total="goods_total">
  106. </el-pagination>
  107. </el-form-item>
  108. </el-form>
  109. </div>
  110. <span slot="footer" class="dialog-footer">
  111. <el-button v-if="goods_total > 0" type="success" round @click="batchSynchronization = true">同步当前页</el-button>
  112. <el-button @click="batch_synchronize_goods = false">关 闭</el-button>
  113. </span>
  114. </el-dialog>
  115. <el-dialog :visible.sync="single_synchronize_goods" width="700px" center title="商品同步默认值">
  116. <div style="height:300px;overflow:auto" id="dispatch-info">
  117. <el-form :model="synchronize_where" :rules="rules" ref="synchronize_where" label-width="20%">
  118. {{--<el-form-item label="方式" prop="level">--}}
  119. {{--<div>--}}
  120. {{--<el-radio-group v-model="synchronize_where.way" prop="way">--}}
  121. {{--<el-radio-button label="1">插件商品类型</el-radio-button>--}}
  122. {{--<el-radio-button label="3">指定商品</el-radio-button>--}}
  123. {{--</el-radio-group>--}}
  124. {{--</div>--}}
  125. {{--</el-form-item>--}}
  126. <el-form-item label="商品ID">
  127. <el-input style="width:50%;" v-model="synchronize_where.goods_id" placeholder="请输入商品ID"></el-input>
  128. <div style="font-size:12px;">输入支持同步的商品ID</div>
  129. </el-form-item>
  130. </el-form>
  131. </div>
  132. <span slot="footer" class="dialog-footer">
  133. <el-button type="success" round @click="dialogVisible = true">开始同步</el-button>
  134. <el-button @click="single_synchronize_goods = false">关 闭</el-button>
  135. </span>
  136. </el-dialog>
  137. <!-- 二次提示弹窗 -->
  138. <el-dialog
  139. title="提示"
  140. :visible.sync="dialogVisible"
  141. top="30vh"
  142. width="30%"
  143. >
  144. <div style="display: flex;">
  145. <svg t="1666317932699" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6253" width="25" height="25"><path d="M512.16 192c231.808 0 437.536 296.384 312.16 489.984-128.896 199.04-494.208 200.96-624.352 0-80.448-124.192-28.288-286.528 79.84-389.568l11.36-10.432C352.96 227.456 430.848 192 512.16 192z m-1.76 388.8a48 48 0 1 0 0 96 48 48 0 0 0 0-96z m1.6-256a36.8 36.8 0 0 0-36.8 36.8V512a36.8 36.8 0 1 0 73.6 0v-150.4A36.8 36.8 0 0 0 512 324.8z" fill="#FA6400" p-id="6254"></path><path d="M512 32C191.936 32 32 191.936 32 512c0 320.064 159.936 480 480 480 320.064 0 480-159.936 480-480C992 191.936 832.064 32 512 32z m0 64c284.736 0 416 131.264 416 416s-131.264 416-416 416S96 796.736 96 512 227.264 96 512 96z" fill="#E02020" fill-opacity=".148" p-id="6255"></path></svg><span style="text-align: center;
  146. line-height: 25px;">是否确认同步</span>
  147. </div>
  148. <span slot="footer" class="dialog-footer">
  149. <el-button @click="dialogVisible = false">取 消</el-button>
  150. <el-button type="primary" @click="updateWidget()">确 定</el-button>
  151. </span>
  152. </el-dialog>
  153. <el-dialog
  154. title="提示"
  155. :visible.sync="batchSynchronization"
  156. top="30vh"
  157. width="30%"
  158. >
  159. <div style="display: flex;">
  160. <svg t="1666317932699" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6253" width="25" height="25"><path d="M512.16 192c231.808 0 437.536 296.384 312.16 489.984-128.896 199.04-494.208 200.96-624.352 0-80.448-124.192-28.288-286.528 79.84-389.568l11.36-10.432C352.96 227.456 430.848 192 512.16 192z m-1.76 388.8a48 48 0 1 0 0 96 48 48 0 0 0 0-96z m1.6-256a36.8 36.8 0 0 0-36.8 36.8V512a36.8 36.8 0 1 0 73.6 0v-150.4A36.8 36.8 0 0 0 512 324.8z" fill="#FA6400" p-id="6254"></path><path d="M512 32C191.936 32 32 191.936 32 512c0 320.064 159.936 480 480 480 320.064 0 480-159.936 480-480C992 191.936 832.064 32 512 32z m0 64c284.736 0 416 131.264 416 416s-131.264 416-416 416S96 796.736 96 512 227.264 96 512 96z" fill="#E02020" fill-opacity=".148" p-id="6255"></path></svg><span style="text-align: center;
  161. line-height: 25px;">是否确认同步</span>
  162. </div>
  163. <span slot="footer" class="dialog-footer">
  164. <el-button @click="dialogVisible = false">取 消</el-button>
  165. <el-button type="primary" @click="batchUpdateWidget()">确 定</el-button>
  166. </span>
  167. </el-dialog>
  168. </div>
  169. </div>
  170. <script>
  171. var app = new Vue({
  172. el: "#app",
  173. delimiters: ['[[', ']]'],
  174. data() {
  175. return {
  176. batchSynchronization:false,
  177. dialogVisible:false,
  178. synchronize_loading:false,
  179. single_synchronize_goods:false,
  180. batch_synchronize_goods:false,
  181. synchronize_where:{
  182. way:0,
  183. plugin_type:'',
  184. goods_id:'',
  185. page:1,
  186. goods_per_page:1000,
  187. },
  188. synchronize_status:false,//同步执行中不能再次点击同步
  189. executed_page:[],
  190. goods_total:0,
  191. goods_per_page:0,
  192. goods_current_page:1,
  193. paginate_loading:false,
  194. plugin_type_list:[],
  195. search_form:{},
  196. times:[],
  197. list:[],
  198. table_loading: false,
  199. //分页
  200. total: 0,
  201. per_page: 0,
  202. current_page: 0,
  203. rules: {},
  204. }
  205. },
  206. created() {
  207. },
  208. mounted() {
  209. let result = this.viewReturn();
  210. this.__initial(result);
  211. this.search(1);
  212. },
  213. methods: {
  214. //视图返回数据
  215. viewReturn() {
  216. return {!! $data?:'{}' !!};
  217. },
  218. //初始化页面数据,请求链接
  219. __initial(data) {
  220. this.plugin_type_list = data.config;
  221. console.log(data);
  222. },
  223. search(page) {
  224. let that = this;
  225. if(this.times && this.times.length>0) {
  226. this.search_form.start_time = this.times[0];
  227. this.search_form.end_time = this.times[1];
  228. }
  229. let json = {
  230. page: page,
  231. search: this.search_form,
  232. };
  233. that.table_loading = true;
  234. that.$http.post("{!! yzWebFullUrl('plugin.goods-default-value.admin.synchronize.list') !!}", json).then(response =>{
  235. if (response.data.result == 1) {
  236. that.list = response.data.data.data;
  237. that.total = response.data.data.total;
  238. that.current_page = response.data.data.current_page;
  239. that.per_page = response.data.data.per_page;
  240. } else {
  241. that.$message.error(response.data.msg);
  242. }
  243. that.table_loading = false;
  244. }), function (res) {
  245. console.log(res);
  246. that.table_loading = false;
  247. };
  248. },
  249. synchronizePopup(way) {
  250. if (way == 1) {
  251. this.batch_synchronize_goods = true;
  252. } else if (way == 3) {
  253. this.single_synchronize_goods = true;
  254. }
  255. this.synchronize_where.way = way;
  256. },
  257. //记录当前切换页数
  258. switchPage(page) {
  259. this.goods_current_page = page;
  260. this.synchronize_where.page = page;
  261. },
  262. //获取同步商品数据进行分页
  263. goodsPaginate() {
  264. let way = this.synchronize_where.way;
  265. if (way == 1) {
  266. if (this.synchronize_where.plugin_type === '') {
  267. this.$message({type: 'warning',message: '请选择商品类型'});
  268. return false;
  269. }
  270. if (this.synchronize_where.goods_per_page > 1000) {
  271. this.$message({type: 'warning',message: '每页数量不能大于1000'});
  272. return false;
  273. }
  274. }
  275. let json = {
  276. way:this.synchronize_where.way,
  277. where:this.synchronize_where
  278. };
  279. this.paginate_loading = true;
  280. this.$http.post("{!! yzWebFullUrl('plugin.goods-default-value.admin.synchronize.goods-page') !!}", json).then(response =>{
  281. if (response.data.result == 1) {
  282. this.goods_total = response.data.data.goods_total;
  283. this.goods_per_page = response.data.data.per_page;
  284. } else {
  285. this.$message({type: 'warning',message: response.data.msg});
  286. }
  287. this.paginate_loading = false;
  288. }), function (res) {
  289. console.log(res);
  290. };
  291. },
  292. batchUpdateWidget() {
  293. this.batchSynchronization =false
  294. if(this.synchronize_status){
  295. this.$message({type: 'warning',message: '同步进行中...'});
  296. return false;
  297. }
  298. if (this.synchronize_where.way == 1) {
  299. if (this.synchronize_where.plugin_type === '') {
  300. this.$message({type: 'warning',message: '请选择商品类型'});
  301. return false;
  302. }
  303. }
  304. if (this.synchronize_where.goods_per_page > 1000) {
  305. this.$message({type: 'warning',message: '每页数量不能大于1000'});
  306. return false;
  307. }
  308. if (this.executed_page.indexOf(this.synchronize_where.page) !== -1) {
  309. this.$message({type: 'warning',message: '当前页('+ this.synchronize_where.page +')已同步'});
  310. return false;
  311. }
  312. let json = {
  313. way:this.synchronize_where.way,
  314. where:this.synchronize_where
  315. };
  316. this.synchronize_status = true;
  317. this.synchronize_loading = true;
  318. this.$http.post("{!! yzWebFullUrl('plugin.goods-default-value.admin.synchronize.batch-update-widget') !!}", json).then(response =>{
  319. if (response.data.result == 1) {
  320. this.$message.success(response.data.msg);
  321. this.executed_page.push(this.synchronize_where.page);
  322. } else {
  323. this.$message({type: 'error',message: response.data.msg});
  324. }
  325. this.synchronize_loading = false;
  326. this.synchronize_status = false;
  327. }), function (res) {
  328. this.synchronize_loading = false;
  329. this.$message.error('请求失败,请刷新再尝试');
  330. console.log(res);
  331. };
  332. },
  333. updateWidget() {
  334. this.dialogVisible =false
  335. if(this.synchronize_status){
  336. this.$message({type: 'warning',message: '同步进行中...'});
  337. return false;
  338. }
  339. if (this.synchronize_where.way == 3) {
  340. if (!this.synchronize_where.goods_id) {
  341. this.$message({type: 'warning',message: '请输入指定商品ID'});
  342. return false;
  343. }
  344. }
  345. let json = {
  346. way:this.synchronize_where.way,
  347. where:this.synchronize_where
  348. };
  349. this.synchronize_status = true;
  350. this.$http.post("{!! yzWebFullUrl('plugin.goods-default-value.admin.synchronize.update') !!}", json).then(response =>{
  351. if (response.data.result == 1) {
  352. this.single_synchronize_goods = false;
  353. this.$message.success(response.data.msg);
  354. location.reload();
  355. } else {
  356. this.$message({type: 'error',message: response.data.msg});
  357. }
  358. this.synchronize_status = false;
  359. }), function (res) {
  360. this.$message.error('请求失败,请刷新再尝试');
  361. console.log(res);
  362. };
  363. },
  364. },
  365. })
  366. </script>
  367. @endsection