synchronousOrderModal.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. import { query } from '@/api/sourceShop'
  88. @Component
  89. export default class SynchronousOrderModal extends Vue {
  90. load = false;
  91. value = false;
  92. type=1;
  93. shopName = '';
  94. shopId:any = null;
  95. shopOptions:Array<any>=[
  96. // {
  97. // label:'犇云聚水潭店铺',
  98. // value:2
  99. // }
  100. ]
  101. skus=''; //skus
  102. styles=''; //款式编码
  103. dateType:any=null;
  104. dateTypeOptions=[{
  105. label:'修改时间',
  106. value:1
  107. },{
  108. label:'创建时间',
  109. value:2
  110. }]
  111. beginDate='';
  112. endDate='';
  113. time:any=null;
  114. setShow(v:boolean){
  115. this.value = v;
  116. }
  117. change(v:any){
  118. if(v){
  119. this.beginDate = v[0];
  120. this.endDate = v[1];
  121. }else{
  122. this.beginDate = '';
  123. this.endDate = '';
  124. }
  125. }
  126. shopChange(v:any){
  127. if(v){
  128. for(const item of this.shopOptions){
  129. if(item.value = v){
  130. this.shopName = item.label
  131. break
  132. }
  133. }
  134. }else{
  135. this.shopName = ''
  136. }
  137. }
  138. btn(){
  139. let value:any={};
  140. let msg = '';
  141. if(!this.shopId){
  142. msg = '店铺名称'
  143. }else{
  144. value.sourceId = this.shopId;
  145. value.sourceName = this.shopName;
  146. }
  147. value.type = this.type;
  148. if(this.type == 1){
  149. msg = this.msgInfo(this.skus,msg,'sku')
  150. value.skus = this.skus.split('\n');
  151. }else if(this.type == 2){
  152. msg = this.msgInfo(this.styles,msg,'款式编码')
  153. value.styles = this.styles.split('\n');
  154. }else if(this.type == 3){
  155. if(this.dateType < 1 || this.dateType > 2){
  156. if(msg){
  157. msg = msg + ',时间类型'
  158. }else{
  159. msg = '时间类型'
  160. }
  161. }
  162. msg = this.msgInfo(this.time,msg,'时间')
  163. value.dateType = this.dateType;
  164. value.beginDate = this.beginDate;
  165. value.endDate = this.endDate;
  166. }
  167. if(msg){
  168. this.$message({
  169. message:msg + '不能为空!',
  170. type: 'warning'
  171. })
  172. return
  173. }
  174. this.load = true;
  175. pullItem(value).then((res:any) => {
  176. this.load = false;
  177. this.value = false;
  178. if(res.data > 0){
  179. (this as any).$message({
  180. message: '成功更新' + res.data + '条数据!',
  181. type: 'success',
  182. });
  183. this.$emit('handleSuccess');
  184. }else{
  185. (this as any).$message({
  186. message: '未更新数据!',
  187. type: 'warning',
  188. });
  189. }
  190. }).catch((err:any) => {
  191. this.load = false;
  192. })
  193. }
  194. msgInfo(data:any,msg:string,title:string){
  195. if(!data){
  196. if(msg){
  197. msg = msg + ',' + title;
  198. }else{
  199. msg = title
  200. }
  201. }
  202. return msg
  203. }
  204. hide(){
  205. this.clear();
  206. }
  207. clear(){
  208. this.type = 1;
  209. this.shopName = '';
  210. this.shopId = '';
  211. this.skus = '';
  212. this.dateType = '';
  213. this.beginDate = '';
  214. this.endDate = '';
  215. this.time = null;
  216. this.styles = '';
  217. }
  218. getShopList() {
  219. this.shopOptions = []
  220. this.load = true
  221. query({
  222. pageNo: 1,
  223. pageSize: 50
  224. }).then((res:any) => {
  225. this.load = false
  226. if (res.data && res.data.records) {
  227. for(const item of res.data.records) {
  228. this.shopOptions.push({
  229. label: item.sourceName,
  230. value: item.id
  231. })
  232. }
  233. }
  234. }).catch(()=>{
  235. this.load = false
  236. })
  237. }
  238. created() {
  239. this.getShopList()
  240. }
  241. }
  242. </script>
  243. <style lang="scss" scoped>
  244. .btn{
  245. width: 100%;
  246. display: flex;
  247. justify-content: flex-end;
  248. }
  249. .type{
  250. width: 100%;
  251. padding: 8px 0;
  252. }
  253. .cont{
  254. width: 100%;
  255. display: flex;
  256. align-items: center;
  257. padding: 8px 0;
  258. .t-title{
  259. width: 100px;
  260. text-align: right;
  261. >span{
  262. color: #F00;
  263. }
  264. }
  265. .right-cont{
  266. width: calc(100% - 100px);
  267. }
  268. }
  269. </style>