KSUpdateDialog.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <el-dialog
  3. width="1200px"
  4. title="创建商品"
  5. :before-close="handleClose"
  6. :visible.sync="visible"
  7. >
  8. <el-form
  9. inline
  10. :model="form"
  11. ref="form"
  12. label-width="180px">
  13. <div class="dialog-info">
  14. <el-form-item
  15. verify
  16. prop="poiId"
  17. label="商家ID"
  18. >
  19. <el-input
  20. v-model="form.poiId"
  21. ></el-input>
  22. </el-form-item>
  23. <div style="width:100%">
  24. <el-button
  25. :disabled="!form.poiId"
  26. @click="handleAdd"
  27. style="margin:5px 0">添加日历计划</el-button>
  28. <el-table :data="form.ticket_specification.calendars">
  29. <el-table-column
  30. prop="origin_amount"
  31. label="原价(单位:分)">
  32. <template slot-scope="scope">
  33. <el-input-number
  34. v-model="scope.row.origin_amount"
  35. :min="0"
  36. :precision="0" />
  37. </template>
  38. </el-table-column>
  39. <el-table-column
  40. prop="actual_amount"
  41. label="实际售价(单位:分)">
  42. <template slot-scope="scope">
  43. <el-input-number
  44. v-model="scope.row.actual_amount"
  45. :min="0"
  46. :precision="0" />
  47. </template>
  48. </el-table-column>
  49. <el-table-column
  50. prop="stock_qty"
  51. label="库存">
  52. <template slot-scope="scope">
  53. <el-input-number
  54. v-model="scope.row.stock_qty"
  55. :min="0"
  56. :precision="0" />
  57. </template>
  58. </el-table-column>
  59. <el-table-column
  60. prop="value_list"
  61. label="日期范围"
  62. width="300"
  63. >
  64. <template slot-scope="scope">
  65. <el-date-picker
  66. style="width:270px"
  67. v-model="scope.row.value_list"
  68. value-format="yyyyMMdd"
  69. type="daterange"
  70. range-separator="至"
  71. start-placeholder="开始日期"
  72. end-placeholder="结束日期">
  73. </el-date-picker>
  74. </template>
  75. </el-table-column>
  76. <el-table-column
  77. prop="action"
  78. label="操作"
  79. width="100">
  80. <template slot-scope="scope">
  81. <el-button @click="handleDelete(scope.$index)">删除</el-button>
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. </div>
  86. </div>
  87. <div class="dialog-btn-wrap">
  88. <el-button
  89. @click="submit"
  90. type="primary">同步</el-button>
  91. </div>
  92. </el-form>
  93. </el-dialog>
  94. </template>
  95. <script>
  96. import { ksUpdatePriceOrStock } from '@/api/otaTicketSale'
  97. import moment from 'moment'
  98. export default {
  99. data () {
  100. return {
  101. visible: false,
  102. uploadUrl: '',
  103. form: {
  104. product_id: '',
  105. poiId: '',
  106. ticket_specification: {
  107. calendars: [],
  108. sku_id: ''
  109. }
  110. },
  111. calendars_value_list: []
  112. }
  113. },
  114. methods: {
  115. show (data) {
  116. this.visible = true
  117. this.form.product_id = data.ksProductId || 0
  118. this.form.ticket_specification.sku_id = data.ks_sku_id || 0
  119. let startDate = moment().format('YYYY-MM-DD HH:mm:ss')
  120. let endDate = moment().add(179, 'days').format('YYYY-MM-DD HH:mm:ss')
  121. startDate = startDate.split(' ')[0].replaceAll('-', '')
  122. endDate = endDate.split(' ')[0].replaceAll('-', '')
  123. this.calendars_value_list = [startDate, endDate]
  124. },
  125. handleClose () {
  126. this.visible = false
  127. },
  128. submit () {
  129. this.$refs.form.validate((valid) => {
  130. if (valid) {
  131. let params = JSON.parse(JSON.stringify(this.form))
  132. ksUpdatePriceOrStock(params, this.form.poiId).then(res => {
  133. if (res.extraInfo.data.error_code) {
  134. this.$message.error(res.extraInfo.data.description)
  135. } else {
  136. this.$message.success('同步成功')
  137. this.handleClose()
  138. this.$emit('update')
  139. }
  140. })
  141. } else {
  142. console.log('error submit!!')
  143. return false
  144. }
  145. })
  146. },
  147. handleAdd () {
  148. this.form.ticket_specification.calendars.push(
  149. {
  150. actual_amount: 0,
  151. calendar_type: 1,
  152. exclude_date_list: [],
  153. origin_amount: 0,
  154. status: 1,
  155. stock_qty: 0,
  156. value_list: this.calendars_value_list || []
  157. }
  158. )
  159. },
  160. handleDelete (index) {
  161. this.form.ticket_specification.calendars.splice(index, 1)
  162. }
  163. },
  164. created () {
  165. }
  166. }
  167. </script>
  168. <style scoped>
  169. .el-tag + .el-tag {
  170. margin-left: 10px;
  171. }
  172. .button-new-tag {
  173. margin-left: 10px;
  174. height: 32px;
  175. line-height: 30px;
  176. padding-top: 0;
  177. padding-bottom: 0;
  178. }
  179. .input-new-tag {
  180. width: 90px;
  181. margin-left: 10px;
  182. vertical-align: bottom;
  183. }
  184. ::v-deep .el-cascader-node {
  185. position: relative;
  186. display: flex;
  187. align-items: center;
  188. padding: 0 30px 0 20px;
  189. height: 34px;
  190. line-height: 34px;
  191. outline: none;
  192. }
  193. </style>