{"id":8268,"date":"2024-06-16T09:01:01","date_gmt":"2024-06-16T01:01:01","guid":{"rendered":""},"modified":"2024-06-16T09:01:01","modified_gmt":"2024-06-16T01:01:01","slug":"vue\u591a\u9009\u6846\u7ed1\u5b9a\u5bf9\u8c61\u6570\u7ec4_vue\u4fee\u6539\u5b50\u7ec4\u4ef6\u6570\u636e\u95ea\u4e86\u4e00\u4e0b","status":"publish","type":"post","link":"https:\/\/mushiming.com\/8268.html","title":{"rendered":"vue\u591a\u9009\u6846\u7ed1\u5b9a\u5bf9\u8c61\u6570\u7ec4_vue\u4fee\u6539\u5b50\u7ec4\u4ef6\u6570\u636e\u95ea\u4e86\u4e00\u4e0b"},"content":{"rendered":"
\u9996\u5148\u6765\u770b\u5b98\u65b9\u6587\u6863\u5bf9\u4e8epicker\u7ec4\u4ef6mode = multiSelector\uff08\u591a\u9009\uff09\u7684\u5c5e\u6027\u8bf4\u660e\u548c\u4ee3\u7801<\/strong><\/p>\n <\/p>\n \u6f14\u793a\u51fa\u6765\u7684\u6548\u679c\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n <\/p>\n <\/p>\n \u57fa\u4e8e\u8fd9\u4e2a\u6f14\u793a\u7684\u6548\u679c\u6211\u4eec\u53ef\u4ee5\u5f88\u76f4\u89c2\u7684\u77e5\u9053\u5404\u4e2a\u5c5e\u6027\u7684\u4f5c\u7528\uff1arange\u662f\u6211\u4eec\u9009\u62e9\u7684\u8303\u56f4\uff0crange-key\u662f\u8981\u5b83\u663e\u793a\u7684\u5185\u5bb9\uff0cvalue\u662f\u6bcf\u6b21\u9009\u5b9a\u7684\u4e0b\u6807\uff08\u7c7b\u4f3c[0,0,0]\u8fd9\u6837\uff09\uff0c@columnchange\u662f\u6ed1\u52a8\u6539\u53d8\u9009\u62e9\u89e6\u53d1\u7684\u65b9\u6cd5\u3002<\/p>\n \u53ef\u4ee5\u770b\u5230\u5b98\u65b9\u6f14\u793a\u662f\u672c\u8eab\u6709\u4e00\u4e2a\u9759\u6001\u6570\u7ec4\u5e76\u4e14\u7ed9\u4e88\u4e86\u4e00\u4e2a\u521d\u59cb\u9009\u62e9\u7684\u503c\u3002<\/p>\n \u90a3\u4e48\u6211\u4eec\u5982\u679c\u8981\u4ece\u63a5\u53e3\u8c03\u53d6\u6570\u636e\u5e76\u52a8\u6001\u7684\u6539\u53d8\u6570\u7ec4\u5462\uff1f<\/strong><\/p>\n \u6bd4\u5982\u8981\u5b9e\u73b0\u4e00\u4e2a\u7701\u5e02\u533a\u7684\u9009\u62e9\uff0c\u5e94\u8be5\u600e\u4e48\u5b9e\u73b0\u5462\uff1f\u6211\u4eec\u5148\u7167\u7740\u5b98\u65b9\u7684\u6837\u4f8b\u5199\u51fa\u6765\uff1a<\/p>\n <\/p>\n \u7701\u5e02\u533a\u7684\u683c\u5f0f\u662f\u8fd9\u6837\u7684\uff0cCode\u53ef\u4ee5\u4e0d\u7528\u7ba1\uff0c\u8fd9\u662f\u6211\u8c03\u7528\u63a5\u53e3\u7528\u7684\u53c2\u6570\u3002<\/p>\n \u8fd0\u884c\u4e4b\u540e\u6211\u4eec\u53d1\u73b0\u4e0d\u592a\u5bf9\u52b2\uff0c\u9996\u5148\u6700\u5927\u7684\u95ee\u9898\u662f\u8fd9\u4e2a\uff1a<\/p>\n \u6bd4\u5982\u6211\u60f3\u6539\u53d8picker\u7684\u9009\u9879\uff0c\u4f8b\u5982\uff0c\u4e00\u5f00\u59cbpicker\u662f\u7a7a\u7684\uff0c\u9009\u62e9\u540e\uff0cpicker\u9009\u9879\u53d8\u6210{1\uff0c2\uff0c3}\uff0c\u518d\u70b9\u51fb\uff0cpicker\u9009\u9879\u53d8\u6210{4\uff0c5\uff0c6}\uff0c\u4f46\u662f\u5728\u4e0a\u8ff0\u4ee3\u7801\u8fd0\u884c\u8fc7\u7a0b\u4e2d\uff0c\u5f53\u6211\u4eec\u70b9\u51fbpicker\u7684\u65f6\u5019\uff0c\u5f39\u51fa\u7684picker\u662f\u7a7a\u7684\uff0c\u5f53\u6211\u70b9\u51fb\u518d\u70b9\u51fb\u7684\u65f6\u5019\uff0c\u5f39\u51fa\u7684picker\u9009\u9879\u53d8\u6210\u4e86{1\uff0c2\uff0c3}\uff0c\u518d\u4e00\u6b21\u70b9\u51fb\u7684\u65f6\u5019\uff0c\u5f39\u51fa\u7684picker\u9009\u9879\u662f{4\uff0c5\uff0c6}\uff0c\u5373\u6211\u4eec\u6bcf\u4e00\u6b21\u70b9\u51fb\uff0c\u5f39\u51fa\u7684picker\u9009\u9879\u662f\u4e0a\u4e00\u6b21\u70b9\u51fb\u7684\u7ed3\u679c\u3002<\/strong><\/p>\n \u8fd9\u662f\u600e\u4e48\u56de\u4e8b\u5462\uff1f\u4e00\u5f00\u59cb\u6211\u8ba4\u4e3a\u662f\u540c\u6b65\u7684\u95ee\u9898\uff0c\u5c31\u662f\u63a5\u53e3\u7684\u6570\u636e\u8fd8\u6ca1\u6765\u53ca\u7ed9multiAdress\u8fd9\u4e2a\u6570\u7ec4\uff0cpicker\u5c31\u5df2\u7ecf\u663e\u793a\u4e86\uff0c\u4e8e\u662f\u4f7f\u7528\u4e86promise\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f46\u662f\u6ca1\u6709\u4f5c\u7528\uff0c\u4e8e\u662f\u6211\u53c8\u60f3\u4e86\u5f88\u4e45\uff0c\u7ec8\u4e8e\u5728\u522b\u4eba\u7684\u535a\u5ba2\u4e2d\u627e\u5230\u4e86\u7b54\u6848\uff0c\u90a3\u5c31\u662f\u4f7f\u7528$set\u6765\u7ed9\u6570\u7ec4\u8d4b\u503c<\/strong>\uff0c\u5927\u5bb6\u53ef\u4ee5\u770b\u8fd9\u7bc7\u535a\u5ba2vue\u4e2d$set\u7528\u6cd5\u8be6\u7ec6\u8bb2\u89e3_vue $set-CSDN\u535a\u5ba2<\/p>\n \u4e8e\u662f\u6211\u5bf9getAddress\u65b9\u6cd5\u8fdb\u884c\u4e86\u6539\u52a8\uff1a<\/p>\n \u8fd0\u884c\u540e\u7ed3\u679c\u6b63\u5e38\u3002<\/p>\n \u4f46\u662f\u7ecf\u8fc7\u4e00\u4e9b\u6d4b\u8bd5\u540e\u53d1\u73b0\uff0c\u6211\u60f3\u52a0\u4e00\u4e9b\u81ea\u5df1\u7684\u60f3\u6cd5\uff0c\u6bd4\u5982\u8981\u600e\u4e48\u5728\u9009\u62e9\u4e4b\u524d\u7ed9\u5b83\u7684\u6587\u672c\u53d8\u6210\u201d\u8bf7\u9009\u62e9\u5730\u533a\u201c\u5462<\/strong>\uff1f\u8fd9\u8fd8\u4e0d\u7b80\u5355\uff1f\u52a0\u4e2a\u5224\u65ad\u5c31\u884c\u4e86\uff1a<\/p>\n \u7136\u800c\u53c8\u51fa\u73b0\u4e86\u65b0\u7684\u95ee\u9898<\/strong>\uff0c\u5982\u679c\u6211\u6253\u5f00picker\u4f46\u6ca1\u6709\u9009\u62e9\u7701\u5e02\u533a\u76f4\u63a5\u786e\u5b9a\uff0c\u6309\u9053\u7406\u5e94\u8be5\u9ed8\u8ba4\u9009\u62e9\u7b2c\u4e00\u4e2a\uff0c\u4f46\u662f\u4e0d\u884c\uff0c\u800c\u4e14\u4e00\u5b9a\u8981\u6ed1\u52a8\u624d\u80fd\u9009\u4e2d\uff0c\u4ec0\u4e48\u6982\u5ff5\u5462\uff1f\u5c31\u662f\u8bf4\u5982\u679c\u6211\u7b2c\u4e00\u4e2a\u7701\u662f\u5929\u6d25\u5e02\uff0c\u4ed6\u540d\u4e0b\u53ea\u6709\u4e00\u4e2a\u5e02\u53eb\u5929\u6d25\u5e02\uff0c\u8fd9\u65f6\u5019\u5982\u679c\u76f4\u63a5\u9009\u62e9\u4ed6\u540e\u9762\u7684\u533a\u4f1a\u51fa\u73b0\u6587\u672c\u201d\u9009\u62e9\u7701 \u9009\u62e9\u5e02 { \u600e\u4e48\u641e\u5b9a\uff1f\u7b80\u5355\uff01\u6211\u7ed9\u4ed6\u7684\u7701\u5e02\u533a\u6765\u4e00\u4e2a\u9ed8\u8ba4\u503c\uff0c\u7ed9\u4e00\u4e2atag\uff0c\u5728@columnchange\u7b2c\u4e00\u6b21\u53d1\u751f\u524d\u663e\u793a\u7684\u662f\u201d\u8bf7\u9009\u62e9\u201c\uff0c@columnchange\u53d1\u751f\u540etag\u7684\u503c\u53d8\u5316\uff0c\u53ef\u4ee5\u663e\u793a\u51fa\u8fd9\u4e2a\u9ed8\u8ba4\u503c\u3002\u4f46\u662f\u5b9e\u9645\u64cd\u4f5c\u540e\u53d1\u73b0\u8fd8\u662f\u4e0d\u884c\uff0c\u867d\u7136\u6ed1\u52a8\u6765\u9009\u62e9\u533a\u540e\u53ef\u4ee5\u663e\u793a\u51fa\u7701\u5e02\u4e86\uff0c\u4f46\u662f\u5982\u679c\u4e0d\u6ed1\u52a8\u533a\u5462<\/strong>\uff1f\u7b54\u6848\u662f\u663e\u800c\u6613\u89c1\u7684\uff0c\u4e0d\u6ed1\u52a8\u7684\u8bdd@columnchange\u5c31\u6ca1\u6709\u53d1\u751f\uff0ctag\u503c\u4e5f\u5c31\u4e0d\u4f1a\u53d1\u751f\u6539\u53d8\uff0c\u4ece\u800c\u9ed8\u8ba4\u7684\u7701\u5e02\u533a\u4e5f\u4e0d\u4f1a\u663e\u793a\u51fa\u6765\u3002<\/p>\n \u8fd9\u4e2a\u5c31\u6709\u70b9\u96be\u641e\u4e86\uff0c\u9664\u975e\u6211\u60f3\u8981\u56de\u5230\u6700\u521d\u7684\u663e\u793a\u6a21\u5f0f\uff0c\u4e4b\u540e\u6211\u53c8\u7814\u7a76\u4e86\u597d\u4e45\uff0c\u53d1\u73b0\u867d\u7136\u5b98\u65b9\u7684\u4ee3\u7801\u91cc\u9762\u6ca1\u7528\u5230\uff0c\u4f46\u662fpicker\u8fd8\u6709\u4e00\u4e2a\u4e8b\u4ef6@change<\/strong>\uff0c\u4e8e\u662f\u6211\u5bf9picker\u8fdb\u884c\u4e86\u6539\u52a8\uff0c\u6dfb\u52a0\u4e86@change\u3002\u4e8b\u5b9e\u8bc1\u660e\uff0c\u7ec4\u4ef6\u7684\u6bcf\u4e2a\u5c5e\u6027\u90fd\u662f\u6709\u5b83\u72ec\u7279\u7684\u4f5c\u7528\u7684\uff0c\u95ee\u9898\u89e3\u51b3\u3002<\/p>\n \u6700\u540e\u7684\u4ee3\u7801<\/strong>\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n \u6548\u679c\u662f\u8fd9\u6837\u7684 \uff0c\u5927\u529f\u544a\u6210\u4e86\uff01<\/p>\n <\/p>\n \u5176\u5b9e\u8fd9\u6bb5\u7a0b\u5e8f\u8fd8\u6709\u5f88\u591a\u5730\u65b9\u53ef\u4ee5\u6539\u8fdb\uff0c\u6211\u611f\u89c9\u5f88\u591a\u5730\u65b9\u7684\u64cd\u4f5c\u90fd\u6709\u70b9\u5197\u4f59\u4e86\uff0c\u4f46\u53ef\u60dc\u6211\u4e5f\u53ea\u662f\u4e00\u4e2a\u524d\u7aef\u83dc\u9e1f\uff0c\u5982\u679c\u5927\u5bb6\u89c9\u5f97\u6709\u54ea\u91cc\u53ef\u4ee5\u6539\u8fdb\u7684\u5730\u65b9\uff0c\u6b22\u8fce\u4ea4\u6d41\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"vue\u591a\u9009\u6846\u7ed1\u5b9a\u5bf9\u8c61\u6570\u7ec4_vue\u4fee\u6539\u5b50\u7ec4\u4ef6\u6570\u636e\u95ea\u4e86\u4e00\u4e0b\u57fa\u4e8e\u8fd9\u4e2a\u6f14\u793a\u7684\u6548\u679c\u6211\u4eec\u53ef\u4ee5\u5f88\u76f4\u89c2\u7684\u77e5\u9053\u5404\u4e2a\u5c5e\u6027\u7684\u4f5c\u7528\uff1arange\u662f\u6211\u4eec\u9009\u62e9...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8268"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=8268"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8268\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=8268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=8268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=8268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<template> <view> <view class=\"uni-title uni-common-pl\">\u591a\u5217\u9009\u62e9\u5668<\/view> <view class=\"uni-list\"> <view class=\"uni-list-cell\"> <view class=\"uni-list-cell-left\"> \u5f53\u524d\u9009\u62e9 <\/view> <view class=\"uni-list-cell-db\"> <picker mode=\"multiSelector\" @columnchange=\"bindMultiPickerColumnChange\" :value=\"multiIndex\" :range=\"multiArray\"> <view class=\"uni-input\">{ \n {multiArray[0][multiIndex[0]]}}\uff0c{ \n {multiArray[1][multiIndex[1]]}}\uff0c{ \n {multiArray[2][multiIndex[2]]}} <\/view> <\/picker> <\/view> <\/view> <\/view> <\/view> <\/template> <script> export default { data() { return { multiArray: [ ['\u4e9a\u6d32', '\u6b27\u6d32'], ['\u4e2d\u56fd', '\u65e5\u672c'], ['\u5317\u4eac', '\u4e0a\u6d77', '\u5e7f\u5dde'] ], multiIndex: [0, 0, 0], } }, methods: { bindMultiPickerColumnChange: function(e) { console.log('\u4fee\u6539\u7684\u5217\u4e3a\uff1a' + e.detail.column + '\uff0c\u503c\u4e3a\uff1a' + e.detail.value) this.multiIndex[e.detail.column] = e.detail.value switch (e.detail.column) { case 0: \/\/\u62d6\u52a8\u7b2c1\u5217 switch (this.multiIndex[0]) { case 0: this.multiArray[1] = ['\u4e2d\u56fd', '\u65e5\u672c'] this.multiArray[2] = ['\u5317\u4eac', '\u4e0a\u6d77', '\u5e7f\u5dde'] break case 1: this.multiArray[1] = ['\u82f1\u56fd', '\u6cd5\u56fd'] this.multiArray[2] = ['\u4f26\u6566', '\u66fc\u5f7b\u65af\u7279'] break } this.multiIndex.splice(1, 1, 0) this.multiIndex.splice(2, 1, 0) break case 1: \/\/\u62d6\u52a8\u7b2c2\u5217 switch (this.multiIndex[0]) { \/\/\u5224\u65ad\u7b2c\u4e00\u5217\u662f\u4ec0\u4e48 case 0: switch (this.multiIndex[1]) { case 0: this.multiArray[2] = ['\u5317\u4eac', '\u4e0a\u6d77', '\u5e7f\u5dde'] break case 1: this.multiArray[2] = ['\u4e1c\u4eac','\u5317\u6d77\u9053'] break } break case 1: switch (this.multiIndex[1]) { case 0: this.multiArray[2] = ['\u4f26\u6566', '\u66fc\u5f7b\u65af\u7279'] break case 1: this.multiArray[2] = ['\u5df4\u9ece', '\u9a6c\u8d5b'] break } break } this.multiIndex.splice(2, 1, 0) break } this.$forceUpdate() }, <\/script> <style> <\/style><\/code><\/pre>\n
<template> <view class=\"box\" v-else-if=\"item.type === 4\"> <view class=\"title\"> { \n { item.title }}\uff1a <\/view> <view class=\"btns\"> <view class=\"btn\" v-if=\"!sheng[0]\"> \u65e0\u4fe1\u606f <\/view> <picker v-else mode=\"multiSelector\" @columnchange=\"bindMultiPickerColumnChange\" class=\"btn\" :value=\"multiIndex\" :range=\"multiAdress\" range-key=\"Name\"> <view>{ \n {multiAdress[0][multiIndex[0]]}} { \n {multiAdress[1][multiIndex[1]]}} { \n {multiAdress[2][multiIndex[2]]}}<\/view> <\/picker> <\/view> <\/view> <\/template> <script> export default { data() { return { shengshiqv: { title: '\u5730\u5740', placeholder: '\u9009\u62e9\u7701\u3001\u5e02\u3001\u533a', placeholderStyle: 'color: #;', event: 'openAddress', sheng: {}, shi: {}, qv: {}, msg: '' }, multiAdress:[ [], [], [] ], multiIndex: [0, 0, 0], sheng: [], shi: [], qv: [], } }, methods: { setQv(item) { console.log(item); this.form.shengshiqv.qv = item; if(this.SimCode == 2) { this.getSims(); } }, setShi(item) { console.log(item); if(this.SimCode == 2) { this.NumStatus = false; this.form.sim.inp = ''; } this.form.shengshiqv.shi = item; this.form.shengshiqv.qv = {}; this.qv = []; this.getAddress(2, item.Code); }, setSheng(item) { console.log(item); if(this.SimCode == 2) { this.NumStatus = false; this.form.sim.inp = ''; } this.form.shengshiqv.sheng = item; this.form.shengshiqv.shi = {}; this.form.shengshiqv.qv = {}; this.shi = []; this.qv = []; this.getAddress(1, item.Code) }, getAddress(level, code) { this.$Req.get({ url: this.$AppConfig.host + '&Code=' + code, \/\/ \u8bf7\u6c42\u5730\u5740 success: resData => { \/\/ \u8bf7\u6c42\u6210\u529f\u56de\u8c03\u51fd\u6570 \/\/ console.log(resData) if(resData.Code == 0) { if(level == 0) { this.sheng = resData.Data; this.multiAdress[0] = this.sheng this.getAddress(1,this.sheng[0].Code) } else if(level == 1) { this.shi = resData.Data; this.multiAdress[1] = this.shi this.getAddress(2,this.shi[0].Code) } else if(level == 2) { this.qv = resData.Data; this.multiAdress[2] = this.qv } } else { uni.showToast({ title: resData.Msg, icon: 'none' }); } } }); this.$forceUpdate() }, bindMultiPickerColumnChange: function(e) { this.tag = 1 console.log('\u4fee\u6539\u7684\u5217\u4e3a\uff1a' + e.detail.column + '\uff0c\u503c\u4e3a\uff1a' + e.detail.value) this.multiIndex[e.detail.column] = e.detail.value switch (e.detail.column) { case 0: \/\/\u62d6\u52a8\u7701 this.setSheng(this.sheng[e.detail.value]) this.multiIndex.splice(1, 1, 0) this.multiIndex.splice(2, 1, 0) break case 1: \/\/\u62d6\u52a8\u5e02 this.setShi(this.shi[e.detail.value]) this.multiIndex.splice(2, 1, 0) break case 2: \/\/\u62d6\u52a8\u533a this.setQv(this.qv[e.detail.value]) break } \/\/ this.$forceUpdate() }, }, onLoad(query) { this.getAddress(0, 0); } } <\/script> <style lang=\"less\" scoped> <\/style><\/code><\/pre>\n
getAddress(level, code) { let type = this.type; this.$Req.get({ url: this.$AppConfig.host + code, \/\/ \u8bf7\u6c42\u5730\u5740 success: resData => { \/\/ \u8bf7\u6c42\u6210\u529f\u56de\u8c03\u51fd\u6570 \/\/ console.log(resData) if(resData.Code == 0) { if(level == 0) { this.sheng = resData.Data; this.$set(this.multiAdress,0,this.sheng) this.getAddress(1,this.sheng[0].Code) } else if(level == 1) { this.shi = resData.Data; this.$set(this.multiAdress,1,this.shi) this.getAddress(2,this.shi[0].Code) } else if(level == 2) { this.qv = resData.Data; this.$set(this.multiAdress,2,this.qv) } } else { uni.showToast({ title: resData.Msg, icon: 'none' }); } } }); this.$forceUpdate() },<\/code><\/pre>\n
<picker v-else mode=\"multiSelector\" @columnchange=\"bindMultiPickerColumnChange\" class=\"btn\" :value=\"multiIndex\" :range=\"multiAdress\" range-key=\"Name\"> <view>{ \n {item.sheng.Name ? item.sheng.Name : '\u9009\u62e9\u7701'}} { \n {item.shi.Name ? item.shi.Name : '\u9009\u62e9\u5e02'}} { \n {item.qv.Name ? item.qv.Name : '\u9009\u62e9\u533a'}}<\/view> <\/picker><\/code><\/pre>\n
\n {\u9009\u62e9\u7684\u533a}}\u201c\u3002<\/p>\n<picker v-else mode=\"multiSelector\" @columnchange=\"bindMultiPickerColumnChange\" @change=\"MultiPickerChange\" class=\"btn\" :value=\"multiIndex\" :range=\"multiAdress\" range-key=\"Name\"> <view>{ \n {tag ? item.sheng.Name : '\u9009\u62e9\u7701'}} { \n {tag ? item.shi.Name : '\u9009\u62e9\u5e02'}} { \n {tag ? item.qv.Name : '\u9009\u62e9\u533a'}}<\/view> <\/picker> tag = 0 MultiPickerChange: function(e) { this.tag = 1 this.form.shengshiqv.sheng = this.sheng[e.detail.value[0]] this.form.shengshiqv.shi = this.shi[e.detail.value[1]] this.form.shengshiqv.qv = this.qv[e.detail.value[2]] }, <\/code><\/pre>\n
<template> <view class=\"box\" v-else-if=\"item.type === 4\"> <view class=\"title\"> { \n { item.title }}\uff1a <\/view> <view class=\"btns\"> <view class=\"btn\" v-if=\"!sheng[0]\"> \u65e0\u4fe1\u606f <\/view> <picker v-else mode=\"multiSelector\" @columnchange=\"bindMultiPickerColumnChange\" @change=\"MultiPickerChange\" class=\"btn\" :value=\"multiIndex\" :range=\"multiAdress\" range-key=\"Name\"> <view>{ \n {tag ? item.sheng.Name : '\u9009\u62e9\u7701'}} { \n {tag ? item.shi.Name : '\u9009\u62e9\u5e02'}} { \n {tag ? item.qv.Name : '\u9009\u62e9\u533a'}}<\/view> <\/picker> <\/view> <\/view> <\/template> <script> export default { data() { return { shengshiqv: { title: '\u5730\u5740', placeholder: '\u9009\u62e9\u7701\u3001\u5e02\u3001\u533a', placeholderStyle: 'color: #;', event: 'openAddress', sheng: {}, shi: {}, qv: {}, msg: '' }, multiAdress:[ [], [], [] ], multiIndex: [0, 0, 0], tag: 0, sheng: [], shi: [], qv: [], } }, methods: { setQv(item) { console.log(item); this.form.shengshiqv.qv = item; if(this.SimCode == 2) { this.getSims(); } }, setShi(item) { console.log(item); if(this.SimCode == 2) { this.NumStatus = false; this.form.sim.inp = ''; } this.form.shengshiqv.shi = item; this.form.shengshiqv.qv = {}; this.qv = []; this.getAddress(2, item.Code); }, setSheng(item) { console.log(item); if(this.SimCode == 2) { this.NumStatus = false; this.form.sim.inp = ''; } this.form.shengshiqv.sheng = item; this.form.shengshiqv.shi = {}; this.form.shengshiqv.qv = {}; this.shi = []; this.qv = []; this.getAddress(1, item.Code) }, getAddress(level, code) { let type = this.type; this.$Req.get({ url: this.$AppConfig.host + '&Code=' + code, \/\/ \u8bf7\u6c42\u5730\u5740 success: resData => { \/\/ \u8bf7\u6c42\u6210\u529f\u56de\u8c03\u51fd\u6570 \/\/ console.log(resData) if(resData.Code == 0) { if(level == 0) { this.sheng = resData.Data; this.$set(this.multiAdress,0,this.sheng) this.getAddress(1,this.sheng[0].Code) } else if(level == 1) { this.shi = resData.Data; this.$set(this.multiAdress,1,this.shi) this.getAddress(2,this.shi[0].Code) } else if(level == 2) { this.qv = resData.Data; this.$set(this.multiAdress,2,this.qv) } } else { uni.showToast({ title: resData.Msg, icon: 'none' }); } } }); this.$forceUpdate() }, MultiPickerChange: function(e) { this.tag = 1 this.form.shengshiqv.sheng = this.sheng[e.detail.value[0]] this.form.shengshiqv.shi = this.shi[e.detail.value[1]] this.form.shengshiqv.qv = this.qv[e.detail.value[2]] }, bindMultiPickerColumnChange: function(e) { this.tag = 1 console.log('\u4fee\u6539\u7684\u5217\u4e3a\uff1a' + e.detail.column + '\uff0c\u503c\u4e3a\uff1a' + e.detail.value) this.multiIndex[e.detail.column] = e.detail.value switch (e.detail.column) { case 0: \/\/\u62d6\u52a8\u7701 this.setSheng(this.sheng[e.detail.value]) this.multiIndex.splice(1, 1, 0) this.multiIndex.splice(2, 1, 0) break case 1: \/\/\u62d6\u52a8\u5e02 this.setShi(this.shi[e.detail.value]) this.multiIndex.splice(2, 1, 0) break case 2: \/\/\u62d6\u52a8\u533a this.setQv(this.qv[e.detail.value]) break } \/\/ this.$forceUpdate() }, }, onLoad(query) { this.getAddress(0, 0); } } <\/script> <style lang=\"less\" scoped> <\/style><\/code><\/pre>\n