synchronousOrderModal.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <vxe-modal v-model="value" id="synchronousOrderModal" width="500" height="400" @hide="hide" transfer show-footer v-loading="load">
  3. <template #title>
  4. <span>商品同步</span>
  5. </template>
  6. <template #default>
  7. <div class="type">
  8. <el-radio-group v-model="type">
  9. <el-radio :label="1">按sku拉取</el-radio>
  10. <el-radio :label="2">按款拉取</el-radio>
  11. <el-radio :label="3">按时间段拉取</el-radio>
  12. </el-radio-group>
  13. </div>
  14. <div class="cont">
  15. <div class="t-title"><span>* </span>店铺名称:</div>
  16. <div class="right-cont">
  17. <el-select v-model="shopId" size="mini" style="width:100%" placeholder="请选择" clearable @change="shopChange">
  18. <el-option
  19. v-for="item in shopOptions"
  20. :key="item.value"
  21. :label="item.label"
  22. :value="item.value">
  23. </el-option>
  24. </el-select>
  25. </div>
  26. </div>
  27. <template v-if="type == 1">
  28. <div class="cont">
  29. <div class="t-title"><span>* </span>sku:</div>
  30. <div class="right-cont">
  31. <el-input v-model="skus" type="textarea" rows="4" size="mini" placeholder="每行一个单号,换行输入"></el-input>
  32. </div>
  33. </div>
  34. </template>
  35. <template v-if="type == 2">
  36. <div class="cont">
  37. <div class="t-title"><span>* </span>款式编码:</div>
  38. <div class="right-cont">
  39. <el-input v-model="styles" type="textarea" rows="4" size="mini" placeholder="每行一个编码,换行输入"></el-input>
  40. </div>
  41. </div>
  42. </template>
  43. <template v-if="type == 3">
  44. <div class="cont">
  45. <div class="t-title"><span>* </span>时间类型:</div>
  46. <div class="right-cont">
  47. <el-select v-model="dateType" size="mini" style="width:100%" placeholder="请选择" clearable>
  48. <el-option
  49. v-for="item in dateTypeOptions"
  50. :key="item.value"
  51. :label="item.label"
  52. :value="item.value">
  53. </el-option>
  54. </el-select>
  55. </div>
  56. </div>
  57. <div class="cont">
  58. <div class="t-title"><span>* </span>时间:</div>
  59. <div class="right-cont">
  60. <el-date-picker
  61. v-model="time"
  62. style="width: 100%;"
  63. size="mini"
  64. type="datetimerange"
  65. clearable
  66. value-format="yyyy-MM-dd HH:mm:ss"
  67. range-separator="-"
  68. start-placeholder="开始日期"
  69. @change="change"
  70. end-placeholder="结束日期">
  71. </el-date-picker>
  72. </div>
  73. </div>
  74. </template>
  75. </template>
  76. <template #footer>
  77. <div class="btn">
  78. <el-button type="primary" size="small" plain @click="clear">清空</el-button>
  79. <el-button type="primary" size="small" @click="btn">确定</el-button>
  80. </div>
  81. </template>
  82. </vxe-modal>
  83. </template>
  84. <script lang="ts">
  85. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  86. import { pullItem } from '@/api/maindataMaterialRelevancy'
  87. @Component
  88. export default class SynchronousOrderModal extends Vue {
  89. load = false;
  90. value = false;
  91. type=1;
  92. shopName = '';
  93. shopId:any = null;
  94. shopOptions=[{
  95. label:'犇云聚水潭店铺',
  96. value:2
  97. }]
  98. skus=''; //skus
  99. styles=''; //款式编码
  100. dateType:any=null;
  101. dateTypeOptions=[{
  102. label:'修改时间',
  103. value:1
  104. },{
  105. label:'创建时间',
  106. value:2
  107. }]
  108. beginDate='';
  109. endDate='';
  110. time:any=null;
  111. setShow(v:boolean){
  112. this.value = v;
  113. }
  114. change(v:any){
  115. if(v){
  116. this.beginDate = v[0];
  117. this.endDate = v[1];
  118. }else{
  119. this.beginDate = '';
  120. this.endDate = '';
  121. }
  122. }
  123. shopChange(v:any){
  124. if(v){
  125. for(const item of this.shopOptions){
  126. if(item.value = v){
  127. this.shopName = item.label
  128. break
  129. }
  130. }
  131. }else{
  132. this.shopName = ''
  133. }
  134. }
  135. btn(){
  136. let value:any={};
  137. let msg = '';
  138. if(!this.shopId){
  139. msg = '店铺名称'
  140. }else{
  141. value.shopId = this.shopId;
  142. value.showName = this.shopName;
  143. }
  144. value.type = this.type;
  145. if(this.type == 1){
  146. msg = this.msgInfo(this.skus,msg,'sku')
  147. value.skus = this.skus.split('\n');
  148. }else if(this.type == 2){
  149. msg = this.msgInfo(this.styles,msg,'款式编码')
  150. value.styles = this.styles.split('\n');
  151. }else if(this.type == 3){
  152. if(this.dateType < 1 || this.dateType > 2){
  153. if(msg){
  154. msg = msg + ',时间类型'
  155. }else{
  156. msg = '时间类型'
  157. }
  158. }
  159. msg = this.msgInfo(this.time,msg,'时间')
  160. value.dateType = this.dateType;
  161. value.beginDate = this.beginDate;
  162. value.endDate = this.endDate;
  163. }
  164. if(msg){
  165. this.$message({
  166. message:msg + '不能为空!',
  167. type: 'warning'
  168. })
  169. return
  170. }
  171. this.load = true;
  172. pullItem(value).then((res:any) => {
  173. this.load = false;
  174. this.value = false;
  175. if(res.data > 0){
  176. (this as any).$message({
  177. message: '成功更新' + res.data + '条数据!',
  178. type: 'success',
  179. });
  180. this.$emit('handleSuccess');
  181. }else{
  182. (this as any).$message({
  183. message: '未更新数据!',
  184. type: 'warning',
  185. });
  186. }
  187. }).catch((err:any) => {
  188. this.load = false;
  189. })
  190. }
  191. msgInfo(data:any,msg:string,title:string){
  192. if(!data){
  193. if(msg){
  194. msg = msg + ',' + title;
  195. }else{
  196. msg = title
  197. }
  198. }
  199. return msg
  200. }
  201. hide(){
  202. this.clear();
  203. }
  204. clear(){
  205. this.type = 1;
  206. this.shopName = '';
  207. this.shopId = '';
  208. this.skus = '';
  209. this.dateType = '';
  210. this.beginDate = '';
  211. this.endDate = '';
  212. this.time = null;
  213. this.styles = '';
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .btn{
  219. width: 100%;
  220. display: flex;
  221. justify-content: flex-end;
  222. }
  223. .type{
  224. width: 100%;
  225. padding: 8px 0;
  226. }
  227. .cont{
  228. width: 100%;
  229. display: flex;
  230. align-items: center;
  231. padding: 8px 0;
  232. .t-title{
  233. width: 100px;
  234. text-align: right;
  235. >span{
  236. color: #F00;
  237. }
  238. }
  239. .right-cont{
  240. width: calc(100% - 100px);
  241. }
  242. }
  243. </style>