edit.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template>
  2. <div class="subPage">
  3. <form class="mainForm">
  4. <ul>
  5. <li class="flex-h">
  6. <span>选择案场:</span>
  7. <div class="flex-item">
  8. <div style="width:50%">
  9. <el-select v-model="cardInfo.CaseId" placeholder="请选择" @change="caseChange" :disabled="disabled">
  10. <el-option
  11. v-for="item in cases"
  12. :key="item.CaseId"
  13. :label="item.CaseName"
  14. :value="item.CaseId">
  15. </el-option>
  16. </el-select>
  17. </div>
  18. </div>
  19. </li>
  20. <li class="flex-h">
  21. <span>卡图片:</span>
  22. <div class="flex-item">
  23. <div>
  24. <a v-if="cardInfo.CardImageUrl && cardInfo.CardImageUrl.indexOf('.mp4') > -1" :href="cardInfo.CardImageUrl" target="blank" style="line-height:40px;">{{cardInfo.CardImageUrl}}</a>
  25. <el-upload
  26. class="avatar-uploader"
  27. action='string'
  28. :http-request="toolClass.upload"
  29. :show-file-list="false"
  30. :on-success="handleAvatarSuccess">
  31. <img v-if="cardInfo.CardImageUrl && cardInfo.CardImageUrl.indexOf('.mp4') === -1" :src="cardInfo.CardImageUrl" class="avatar">
  32. <el-button type="primary" size="mini" v-if="!cardInfo.CardImageUrl || cardInfo.CardImageUrl.indexOf('.mp4') > -1">{{cardInfo.CardImageUrl.indexOf('.mp4') > -1 ? '更换' : '上传'}}文件</el-button>
  33. <!-- <i v-else class="el-icon-plus avatar-uploader-icon"></i> -->
  34. </el-upload>
  35. </div>
  36. </div>
  37. </li>
  38. <li class="flex-h">
  39. <span>卡名称:</span>
  40. <div class="flex-item">
  41. <div style="width:200px;">
  42. <el-input
  43. placeholder="请输入"
  44. v-model="cardInfo.GymCardName"
  45. clearable
  46. :disabled="disabled">
  47. </el-input>
  48. </div>
  49. </div>
  50. </li>
  51. <li class="flex-h">
  52. <span>卡类型:</span>
  53. <div class="flex-item">
  54. <div>
  55. <el-select v-model="cardInfo.GymTypeId" placeholder="请选择" :disabled="disabled">
  56. <el-option
  57. v-for="item in GymTypeList"
  58. :key="item.id"
  59. :label="item.name"
  60. :value="item.id">
  61. </el-option>
  62. </el-select>
  63. </div>
  64. </div>
  65. </li>
  66. <li class="flex-h">
  67. <span>卡价格:</span>
  68. <div class="flex-item">
  69. <div style="width:200px;">
  70. <el-input
  71. placeholder="请输入"
  72. v-model="cardInfo.Price"
  73. clearable
  74. :disabled="disabled">
  75. </el-input>
  76. </div>
  77. </div>
  78. </li>
  79. <li class="flex-h">
  80. <span>总张数:</span>
  81. <div class="flex-item">
  82. <div style="width:200px;">
  83. <el-input
  84. placeholder="请输入"
  85. v-model="cardInfo.TotalCount"
  86. clearable
  87. :disabled="disabled">
  88. </el-input>
  89. </div>
  90. </div>
  91. </li>
  92. <li class="flex-h">
  93. <span>发送类型:</span>
  94. <div class="flex-item">
  95. <div>
  96. <el-radio v-model="cardInfo.SendType" label="channel" :disabled="disabled">渠道</el-radio>
  97. <el-radio v-model="cardInfo.SendType" label="case" :disabled="disabled">案场</el-radio>
  98. <el-radio v-model="cardInfo.SendType" label="system" :disabled="disabled">系统</el-radio>
  99. </div>
  100. </div>
  101. </li>
  102. <li class="flex-h" v-if="cardInfo.SendType === 'channel'">
  103. <span>选择渠道:</span>
  104. <div class="flex-item">
  105. <div style="width:50%">
  106. <el-select v-model="cardInfo.ChannelId" placeholder="请选择" :disabled="disabled">
  107. <el-option
  108. v-for="item in channelList"
  109. :key="item.ChannelId"
  110. :label="item.ChannelName"
  111. :value="item.ChannelId">
  112. </el-option>
  113. </el-select>
  114. </div>
  115. </div>
  116. </li>
  117. <li class="flex-h">
  118. <span>卡有效时间:</span>
  119. <div class="flex-item">
  120. <div>
  121. <div class="addLine flex-h" style="align-item:center;margin-bottom:20px;">
  122. <el-date-picker
  123. value-format="yyyy-MM-dd 00:00:00"
  124. v-model="cardInfo.StartDate"
  125. type="date"
  126. placeholder="选择起始日期"
  127. :disabled="disabled">
  128. </el-date-picker>
  129. <span style="line-height:40px;">至</span>
  130. <el-date-picker
  131. value-format="yyyy-MM-dd 23:59:59"
  132. v-model="cardInfo.EndDate"
  133. type="date"
  134. placeholder="选择截止日期"
  135. :disabled="disabled">
  136. </el-date-picker>
  137. </div>
  138. </div>
  139. </div>
  140. </li>
  141. <li class="flex-h">
  142. <span>分享描述:</span>
  143. <div class="flex-item">
  144. <div>
  145. <el-input
  146. type="textarea"
  147. :rows="2"
  148. placeholder="请输入"
  149. v-model="cardInfo.CardShareInfo">
  150. </el-input>
  151. </div>
  152. </div>
  153. </li>
  154. <li class="flex-h">
  155. <span>规则描述:</span>
  156. <div class="flex-item">
  157. <div>
  158. <el-input
  159. type="textarea"
  160. :rows="2"
  161. placeholder="请输入"
  162. v-model="cardInfo.CardUseRule">
  163. </el-input>
  164. </div>
  165. </div>
  166. </li>
  167. <li class="flex-h">
  168. <span>使用说明:</span>
  169. <div class="flex-item">
  170. <div>
  171. <el-input
  172. type="textarea"
  173. :rows="2"
  174. placeholder="请输入"
  175. v-model="cardInfo.CardUseInstruction">
  176. </el-input>
  177. </div>
  178. </div>
  179. </li>
  180. <li style="text-align:center">
  181. <el-button type="primary" size="mini" @click="submit">保存</el-button>
  182. <el-button type="danger" size="mini" @click="cancel">取消</el-button>
  183. </li>
  184. </ul>
  185. </form>
  186. </div>
  187. </template>
  188. <script>
  189. import { mapState, createNamespacedHelpers } from 'vuex'
  190. const { mapActions: mapGymCardActions } = createNamespacedHelpers('gymcard')
  191. const { mapState: mapChannelState, mapActions: mapChannelActions } = createNamespacedHelpers('channel')
  192. export default {
  193. name: '',
  194. data () {
  195. return {
  196. disabled: false,
  197. date: '',
  198. courseList: [],
  199. videoOff: false,
  200. total: 0,
  201. type: this.$route.query.type,
  202. isEdit: this.$route.query.id === undefined ? 0 : 1,
  203. GymTypeList: [{ // 卡类型
  204. id: 'once',
  205. name: '次卡'
  206. }, {
  207. id: 'month',
  208. name: '月卡'
  209. }, {
  210. id: 'quarter',
  211. name: '季卡'
  212. }, {
  213. id: 'year',
  214. name: '年卡'
  215. }],
  216. ChannelList: [], // 渠道列表
  217. TypeList: [], // 类型列表
  218. GoodsList: [], // 商品列表
  219. cardInfo: {
  220. GymCardId: '',
  221. CardImageUrl: '',
  222. GymCardName: '',
  223. GymTypeId: '',
  224. Price: '',
  225. TotalCount: '',
  226. SendType: '',
  227. ChannelId: '',
  228. StartDate: '',
  229. EndDate: '',
  230. CardShareInfo: '',
  231. CardUseRule: '',
  232. CardUseInstruction: '',
  233. CaseId: '',
  234. OrgId: ''
  235. },
  236. postData: {
  237. page: 1,
  238. pagesize: 10,
  239. },
  240. }
  241. },
  242. mounted () {
  243. this.$nextTick(function () {
  244. this.GetChannelListList({
  245. caseid: this.defaultCaseId,
  246. page: 1,
  247. pagesize: 10000
  248. }).then(() => {
  249. if (this.$route.query.id) {
  250. this.disabled = true
  251. this.getGymCardById({
  252. id: this.$route.query.id
  253. }).then((res) => {
  254. // console.log(JSON.stringify(res.Card))
  255. this.cardInfo = res
  256. })
  257. }
  258. })
  259. })
  260. },
  261. computed: {
  262. ...mapChannelState({
  263. channelList: x => x.channelList,
  264. }),
  265. ...mapState({
  266. cases: x => x.app.cases.list,
  267. defaultCaseId: x => x.app.cases.default,
  268. OrgId: x => x.app.user.OrgId,
  269. }),
  270. CaseId: {
  271. get () {
  272. return this.postData.caseid || this.defaultCaseId
  273. },
  274. set (val) {
  275. this.postData.caseid = val
  276. }
  277. }
  278. },
  279. methods: {
  280. ...mapGymCardActions([
  281. 'addGymCard',
  282. 'getGymCardById',
  283. 'editGymCard',
  284. ]),
  285. ...mapChannelActions([
  286. 'GetChannelListList',
  287. ]),
  288. caseChange () { // 选择案场
  289. this.GetChannelListList({
  290. caseid: this.cardInfo.CaseId,
  291. page: 1,
  292. pagesize: 10000
  293. })
  294. this.cardInfo.ChannelId = ''
  295. },
  296. submit () { // 保存
  297. // console.log(this.cardInfo.StartDate)
  298. if (this.$route.query.id) {
  299. this.cardInfo.TotalCount = this.cardInfo.TotalCount - 0
  300. this.editGymCard(this.cardInfo).then((res) => {
  301. this.$alert('操作成功', '提示', {
  302. confirmButtonText: '确定',
  303. callback: action => {
  304. this.$router.push({ name: 'bodyBuildingCardManager' })
  305. }
  306. })
  307. })
  308. } else {
  309. this.cardInfo.OrgId = this.OrgId
  310. this.cardInfo.TotalCount = this.cardInfo.TotalCount - 0
  311. this.addGymCard(this.cardInfo).then((res) => {
  312. this.$alert('操作成功', '提示', {
  313. confirmButtonText: '确定',
  314. callback: action => {
  315. this.$router.push({ name: 'bodyBuildingCardManager' })
  316. }
  317. })
  318. })
  319. }
  320. },
  321. cancel () { // 取消
  322. this.$router.push({ name: 'bodyBuildingCardManager' })
  323. },
  324. handleAvatarSuccess (res, file) {
  325. this.cardInfo.CardImageUrl = res.result.url
  326. }
  327. }
  328. }
  329. </script>
  330. <!-- Add "scoped" attribute to limit CSS to this component only -->
  331. <style lang="scss" scoped>
  332. .addLine {
  333. > * {
  334. margin-right: 10px;
  335. }
  336. }
  337. .mainForm > ul > li > div > div > button {
  338. margin-top: 0;
  339. }
  340. </style>