Point.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view>
  3. <uni-nav-bar fixed="true" height="80px" dark color="#ffffff" backgroundColor="#1989fa" shadow left-icon="home"
  4. title="巡更点" @clickLeft="GoBackHome()"/>
  5. <button style="height:40px;line-height:40px;border-radius:4px;background-color:#1989fa;color:#fff;border:#1989fa;margin:5px 20px;" class="button" type="info" @click="NfcScan()">NFC感应</button>
  6. <uni-section type="line" padding style="margin-left:5px">
  7. <text class="uni-subtitle">巡更点编号</text>
  8. <uni-easyinput style="margin: 10px 10px;width: 95%;" disabled class="uni-mt-4" trim="all" v-model="nfcId"></uni-easyinput>
  9. </uni-section>
  10. <uni-section type="line" padding style="margin-left:5px">
  11. <text class="uni-subtitle">巡更点名称</text>
  12. <uni-easyinput style="margin: 10px 10px;width: 95%;" class="uni-mt-5" trim="all" v-model="pointname"></uni-easyinput>
  13. </uni-section>
  14. <text class="uni-subtitle" style="margin-left:5px">项目楼栋配置</text>
  15. <view class="checkout">
  16. <view class="select_box">
  17. <picker @change="ChangeProject" :range="exitDataproject">
  18. <label class="">{{ currExitproject }}</label>
  19. </picker>
  20. </view>
  21. <view class="select_box">
  22. <picker @change="ChangeBuild" :range="exitDatabuild">
  23. <label class="">{{ currExitbuild }}</label>
  24. </picker>
  25. </view>
  26. <view class="select_box">
  27. <picker @change="ChangeHouse" :range="exitDatahouse">
  28. <label class="">{{ currExithouse }}</label>
  29. </picker>
  30. </view>
  31. </view>
  32. <button style="height:40px;line-height:40px;border-radius:4px;background-color:#1989fa;color:#fff;border:#1989fa;margin:5px 20px;" class="button" type="info" @click="SaveData()">确定</button>
  33. </view>
  34. </template>
  35. <script>
  36. import NFC from "../../static/js/nfc.js"
  37. export default{
  38. data(){
  39. return{
  40. nfcId:'',
  41. pointname:'',
  42. exitDataproject:[],
  43. exitDatabuild:[],
  44. exitDatahouse:[],
  45. currIndex:0,
  46. currExitproject:'请选择项目',
  47. currExitbuild:'请选择楼栋',
  48. currExithouse:'请选择房间'
  49. }
  50. },
  51. created(){
  52. this.GetProjectList()
  53. },
  54. methods:{
  55. async NfcScan(){
  56. // 这里用异步获取读取到的NFC数据
  57. this.nfcId =await NFC.listenNFCStatus()
  58. console.log("nfcId:---"+this.nfcId)
  59. if(!this.nfcId) return
  60. },
  61. SaveData(){
  62. if(this.nfcId==''){
  63. uni.showToast({
  64. icon:'none',
  65. title:'巡更点编号不能为空'
  66. })
  67. return
  68. }
  69. if(this.pointname==''){
  70. uni.showToast({
  71. icon:'none',
  72. title:'巡更点名称不能为空'
  73. })
  74. return
  75. }
  76. if(this.currExitproject=='请选择项目'||this.currExitbuild=='请选择楼栋'||this.currExithouse=='请选择房间'){
  77. uni.showToast({
  78. icon:'none',
  79. title:'请选择项目楼栋配置'
  80. })
  81. return
  82. }
  83. var data = {
  84. pointCode: this.nfcId,
  85. pointname:this.pointname,
  86. pcode:this.currExitproject.slice(this.currExitproject.indexOf('|')+1),
  87. bcode:this.currExitbuild.slice(this.currExitbuild.indexOf('|')+1),
  88. hcode:this.currExithouse.slice(this.currExithouse.indexOf('|')+1)
  89. }
  90. this.$api.PointAdd(data).then(res=>{
  91. if(!res.isSuccess){
  92. uni.showToast({
  93. icon: 'none',
  94. title: res.errMsg
  95. });
  96. return
  97. }
  98. uni.showToast({
  99. icon: 'none',
  100. title: res.msg
  101. });
  102. setTimeout(function() {
  103. uni.navigateTo({
  104. url:"../index/home"
  105. })
  106. }, 1500);
  107. })
  108. },
  109. GoBackHome(){
  110. uni.navigateTo({
  111. url:"/pages/index/home"
  112. })
  113. },
  114. ChangeProject(e) {
  115. this.currIndex = e.target.value;
  116. this.currExitproject = this.exitDataproject[this.currIndex]
  117. // console.info("currIndex:", e.target.value+"==="+this.currExitproject)
  118. this.GetBuildList()
  119. },
  120. ChangeBuild(e){
  121. this.currIndex = e.target.value;
  122. this.currExitbuild = this.exitDatabuild[this.currIndex]
  123. console.info("currIndex:", e.target.value)
  124. this.GetHouseList()
  125. },
  126. ChangeHouse(e){
  127. this.currIndex = e.target.value;
  128. this.currExithouse = this.exitDatahouse[this.currIndex]
  129. console.info("currIndex:", e.target.value)
  130. },
  131. GetProjectList(){
  132. this.$api.GetProjectList({}).then(res=>{
  133. if (res.length !=undefined &&res.length>0) {
  134. var project=[]
  135. res.filter(function (item, i) {
  136. project.push(item.pname+"|"+item.pcode)
  137. })
  138. this.exitDataproject= project
  139. }else{
  140. }
  141. })
  142. },
  143. GetBuildList(){
  144. var data ={
  145. value:this.currExitproject.slice(this.currExitproject.indexOf('|')+1)
  146. }
  147. this.$api.GetBuildList(data).then(res=>{
  148. if (res.length !=undefined &&res.length>0) {
  149. var build=[]
  150. res.filter(function (item, i) {
  151. build.push(item.bname+"|"+item.bcode)
  152. })
  153. this.exitDatabuild = build
  154. }else{
  155. }
  156. })
  157. },
  158. GetHouseList(){
  159. var data = {
  160. value:this.currExitbuild.slice(this.currExitbuild.indexOf('|')+1)
  161. }
  162. this.$api.GetHouseListByBcode(data).then(res=>{
  163. if (res.length !=undefined &&res.length>0) {
  164. var house=[]
  165. res.filter(function (item, i) {
  166. house.push(item.hname+"|"+item.hcode)
  167. })
  168. this.exitDatahouse = house
  169. }else{
  170. }
  171. })
  172. },
  173. }
  174. }
  175. </script>
  176. <style lang="scss">
  177. .checkout{
  178. padding: 30rpx;
  179. .select_box{
  180. height: 35px;
  181. line-height: 35px;
  182. border: 1px solid #d6dbe5;
  183. border-radius: 6rpx;
  184. font-size: 30rpx;
  185. text-align: center;
  186. margin-bottom: 10rpx;
  187. }
  188. }
  189. </style>