phoneBillPro.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. define({
  2. template: `
  3. <div>
  4. <el-form ref="auth">
  5. <div class="vue-main-title">
  6. <div class="vue-main-title-left"></div>
  7. <div class="vue-main-title-content">话费充值</div>
  8. </div>
  9. <div style="margin:0 auto;width:80%;">
  10. <el-form-item label="话费充值">
  11. <el-radio v-model="form.phone_bill_pro_goods.is_open" :label="1">开启</el-radio>
  12. <el-radio v-model="form.phone_bill_pro_goods.is_open" :label="0">关闭</el-radio>
  13. <div class="form-item_tips">首次发布商品,先点击发布商品,再重新编辑商品,设置话费充值规格!</div>
  14. </el-form-item >
  15. <el-form-item label=" ">
  16. <el-table :data="list" border style="width: 100%">
  17. <el-table-column prop="spec" label="类型" width='120' ></el-table-column>
  18. <el-table-column prop="charge_type" label="话费类型" width='240' >
  19. <template slot-scope="scope">
  20. <el-select v-model="scope.row.charge_type" placeholder="请选择">
  21. <el-option
  22. v-for="item in chargeTypeList"
  23. :key="item.value"
  24. :label="item.label"
  25. :value="item.value">
  26. </el-option>
  27. </el-select>
  28. </template>
  29. </el-table-column>
  30. <el-table-column prop="desc" label="自定义文案" width='240' >
  31. <template slot-scope="scope">
  32. <el-input v-model="scope.row.desc" type="textarea" style="padding-right:10px"></el-input>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="面值">
  36. <!-- 分行显示 -->
  37. <template slot-scope="scope">
  38. <div class="moreCol">
  39. <el-table border :data='scope.row.specValueList' >
  40. <el-table-column prop='spec_value' label="名称" >
  41. <template slot-scope="scope">
  42. <span>{{scope.row.spec_value}}</span>
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. </div>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="状态">
  50. <!-- 分行显示 -->
  51. <template slot-scope="scope">
  52. <div class="moreCol">
  53. <el-table border :data='scope.row.statusList'>
  54. <el-table-column prop='status' >
  55. <template slot-scope="scope">
  56. <el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0"></el-switch>
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. </div>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="关联话费面值">
  64. <!-- 分行显示 -->
  65. <template slot-scope="scope">
  66. <div class="moreCol">
  67. <el-table border :data='scope.row.typeList' >
  68. <el-table-column prop='type' label="名称" >
  69. <template slot-scope="scope">
  70. <el-select v-model="scope.row.type" placeholder="请选择">
  71. <el-option
  72. v-for="item in typeList"
  73. :key="item.value"
  74. :label="item.label"
  75. :value="item.value">
  76. </el-option>
  77. </el-select>
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. </div>
  82. </template>
  83. </el-table-column>
  84. <el-table-column v-if="channel == 'aggregation-cps'" label="关联商品ID">
  85. <!-- 分行显示 -->
  86. <template slot-scope="scope">
  87. <div class="moreCol">
  88. <el-table border :data='scope.row.typeList' >
  89. <el-table-column prop='type' label="名称" >
  90. <template slot-scope="scope">
  91. <el-input v-model="scope.row.bingbird_goods_id" placeholder="请输入内容"></el-input>
  92. </template>
  93. </el-table-column>
  94. </el-table>
  95. </div>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <div class="form-item_tips">如果您修改了商品规格,需要手动设置关联!</div>
  100. </el-form-item>
  101. <el-form-item label="顶部banner图片" label-width="113px">
  102. <el-input v-model="form.phone_bill_pro_goods.banner" style="width: 60%;">
  103. <template slot="append"><span @click="displaySelectMaterialPopup('thumb')">选择图片</span></template>
  104. </el-input>
  105. </el-form-item>
  106. <el-form-item label=" " label-width="113px">
  107. <div style="position: relative;">
  108. <img :src="form.phone_bill_pro_goods.banner" style="width: 150px; height: 150px; border-radius: 5px; cursor: pointer;object-fit:cover;" />
  109. <i class="el-icon-close" style="position: absolute;margin-left: 10px;" @click="btnDelete"></i>
  110. </div>
  111. <div class="form-item_tips">建议尺寸: 640 * 640 ,或正方型图片</div>
  112. </el-form-item>
  113. </div>
  114. </el-form>
  115. <upload-multimedia-img
  116. :upload-show="showSelectMaterialPopup"
  117. :type="materialType"
  118. :name="formFieldName"
  119. selNum="one"
  120. @replace="showSelectMaterialPopup = !showSelectMaterialPopup"
  121. @sure="selectedMaterial"
  122. ></upload-multimedia-img>
  123. </div>
  124. `,
  125. style: `
  126. .moreCol .el-table thead{
  127. display:none
  128. }
  129. .moreCol .el-table--border, .el-table--group{
  130. border: none;
  131. }
  132. .el-table .cell{
  133. padding-right:0 !important;
  134. }
  135. .el-table th > .cell {
  136. text-align: center;
  137. }
  138. .el-table .cell {
  139. text-align: center;
  140. }
  141. `,
  142. props: {
  143. form: {
  144. default() {
  145. return {};
  146. },
  147. },
  148. formKey: {
  149. type: String,
  150. },
  151. },
  152. data() {
  153. return {
  154. showSelectMaterialPopup: false,
  155. materialType: "1",
  156. formFieldName: "",
  157. channel: '',
  158. list: [
  159. {
  160. spec: '',
  161. status:"",
  162. desc:"",
  163. charge_type:"",
  164. specValueList:[
  165. {
  166. spec_value:''
  167. },
  168. {
  169. spec_value:''
  170. },
  171. {
  172. spec_value:''
  173. }
  174. ],
  175. typeList:[
  176. {
  177. type:'',
  178. bingbird_goods_id:0
  179. },
  180. {
  181. type:'',
  182. bingbird_goods_id:0
  183. },
  184. {
  185. type:'',
  186. bingbird_goods_id:0
  187. }
  188. ],
  189. statusList: [
  190. {status: 0},
  191. {status: 0},
  192. {status: 0},
  193. ]
  194. },
  195. {
  196. spec: '',
  197. status:"",
  198. desc:"",
  199. charge_type:"",
  200. specValueList:[
  201. {
  202. spec_value:''
  203. },
  204. {
  205. spec_value:''
  206. },
  207. {
  208. spec_value:''
  209. }
  210. ],
  211. typeList:[
  212. {
  213. type:'',
  214. bingbird_goods_id:0
  215. },
  216. {
  217. type:'',
  218. bingbird_goods_id:0
  219. },
  220. {
  221. type:'',
  222. bingbird_goods_id:0
  223. }
  224. ],
  225. statusList: [
  226. {status: 0},
  227. {status: 0},
  228. {status: 0},
  229. ]
  230. }
  231. ],
  232. typeList: [{
  233. value: 1,
  234. label: '50'
  235. }, {
  236. value: 2,
  237. label: '100'
  238. }, {
  239. value: 3,
  240. label: '200'
  241. }],
  242. chargeTypeList: [{
  243. value: 0,
  244. label: '慢充'
  245. }, {
  246. value: 1,
  247. label: '快充'
  248. }],
  249. }
  250. },
  251. created() {
  252. // console.log(this.form,115);
  253. // this.form.options = [
  254. // {
  255. // "goods_option_id": 79,
  256. // "desc": "",
  257. // "status": 0,
  258. // "charge_type": "1",
  259. // "type": "1",
  260. // "spec": "蓝色",
  261. // "spec_value": "规格1"
  262. // },
  263. // {
  264. // "goods_option_id": 80,
  265. // "desc": "",
  266. // "status": 0,
  267. // "charge_type": "0",
  268. // "type": "2",
  269. // "spec": "蓝色",
  270. // "spec_value": "规格2"
  271. // },
  272. // {
  273. // "goods_option_id": 81,
  274. // "desc": "",
  275. // "status": 0,
  276. // "charge_type": "1",
  277. // "type": "3",
  278. // "spec": "绿色",
  279. // "spec_value": "规格1"
  280. // },
  281. // {
  282. // "goods_option_id": 82,
  283. // "desc": "",
  284. // "status": 0,
  285. // "charge_type": "0",
  286. // "type": "1",
  287. // "spec": "绿色",
  288. // "spec_value": "规格2"
  289. // },
  290. // {
  291. // "goods_option_id": 110,
  292. // "desc": "",
  293. // "status": 0,
  294. // "charge_type": "1",
  295. // "type": "2",
  296. // "spec": "蓝色",
  297. // "spec_value": "规格3"
  298. // },
  299. // {
  300. // "goods_option_id": 111,
  301. // "desc": "1",
  302. // "status": 0,
  303. // "charge_type": "0",
  304. // "type": "1",
  305. // "spec": "绿色",
  306. // "spec_value": "规格3"
  307. // }
  308. // ]
  309. this.channel = this.form.channel;
  310. if(this.form.options.length == 0){
  311. this.list = []
  312. return
  313. }
  314. let itemList = []
  315. let chargeTypeList = []
  316. let descList = []
  317. console.log(this.form.options)
  318. for(let item of this.form.options){
  319. itemList.push(item.spec)
  320. chargeTypeList.push(item.charge_type)
  321. descList.push(item.desc)
  322. }
  323. itemList = Array.from(new Set(itemList))
  324. chargeTypeList = Array.from(new Set(chargeTypeList))
  325. descList = Array.from(new Set(descList))
  326. this.list[0].spec = itemList[0]
  327. this.list[1].spec = itemList[1]
  328. this.list[0].charge_type = chargeTypeList[0]
  329. this.list[1].charge_type = chargeTypeList[1]
  330. this.list[0].desc = descList[0]
  331. this.list[1].desc = descList[1]
  332. this.form.options.slice(0,3).forEach((item,index) => {
  333. this.list[0].typeList[index].type = item.type
  334. this.list[0].typeList[index].bingbird_goods_id = item.bingbird_goods_id
  335. this.list[0].specValueList[index].spec_value = item.spec_value
  336. this.list[0].statusList[index].status = item.status;
  337. })
  338. this.form.options.slice(3,6).forEach((item,index) => {
  339. this.list[1].typeList[index].type = item.type
  340. this.list[1].typeList[index].bingbird_goods_id = item.bingbird_goods_id
  341. this.list[1].specValueList[index].spec_value = item.spec_value
  342. this.list[1].statusList[index].status = item.status;
  343. })
  344. console.log(itemList,this.list,'itemList');
  345. },
  346. methods: {
  347. validate() {
  348. this.form.options.forEach((item,index) => {
  349. if(index < 3){
  350. item.desc = this.list[0].desc
  351. item.charge_type = this.list[0].charge_type
  352. item.spec = this.list[0].spec
  353. item.spec_value = this.list[0].specValueList[index].spec_value
  354. item.type = this.list[0].typeList[index].type
  355. item.bingbird_goods_id = this.list[0].typeList[index].bingbird_goods_id
  356. item.status = this.list[0].statusList[index].status;
  357. }else{
  358. item.desc = this.list[1].desc
  359. item.charge_type = this.list[1].charge_type
  360. item.spec = this.list[1].spec
  361. item.spec_value = this.list[1].specValueList[index - 3].spec_value
  362. item.type = this.list[1].typeList[index - 3].type
  363. item.bingbird_goods_id = this.list[1].typeList[index - 3].bingbird_goods_id
  364. item.status = this.list[1].statusList[index - 3].status;
  365. }
  366. })
  367. // this.form.options.forEach(item => {
  368. // item.status = this.form.phone_bill_pro_goods.is_open
  369. // })
  370. return {
  371. status:this.form.phone_bill_pro_goods.is_open,
  372. banner:this.form.phone_bill_pro_goods.banner,
  373. options:this.form.options
  374. }
  375. },
  376. displaySelectMaterialPopup(fieldName = "thumb", type = 1) {
  377. this.formFieldName = fieldName;
  378. this.showSelectMaterialPopup = !this.showSelectMaterialPopup;
  379. this.materialType = String(type);
  380. },
  381. selectedMaterial(name, image, imageUrl) {
  382. this.form.phone_bill_pro_goods.banner = imageUrl[0].url
  383. },
  384. btnDelete(){
  385. this.form.phone_bill_pro_goods.banner = ""
  386. }
  387. },
  388. });