index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <view class="work-container">
  3. <view class="header">
  4. <u-search placeholder="请输入客户名称" :clearabled="true" @clear="searchDept" @custom="searchDept"
  5. v-model="search.deptName" @search="searchDept"></u-search>
  6. </view>
  7. <view style="margin-top: 10px">
  8. <uni-card v-if="item.parentId !==0" v-for="item in deptList" :title="item.deptName"
  9. :extra="item.createTime">
  10. <view style="position: relative">
  11. <view>联系人:{{item.leader}}</view>
  12. <view>联系电话:{{item.phone}}</view>
  13. <view style="width: 50px;position: absolute;right:-10px;bottom:0px"><u-button @click="toUser(item)"
  14. type="primary" :plain="true" size="mini" text="查看人员"></u-button>
  15. </view>
  16. <view style="width: 50px;position: absolute;right:90rpx;bottom:0rpx"><u-button type="success"
  17. @click="toDeviceList(item)" :plain="true" size="mini" text="查看设备"></u-button>
  18. </view>
  19. <view style="width: 50px;position: absolute;right:200rpx;bottom:0rpx"><u-button type="warning "
  20. @click="toDel(item)" :plain="true" size="mini" text="删除客户"></u-button>
  21. </view>
  22. </view>
  23. </uni-card>
  24. </view>
  25. <view style="position: fixed;bottom: 0px;text-align: center;width: 100%">
  26. <u-button type="primary" text="新增客户" @click="newUser"></u-button>
  27. </view>
  28. <u-modal :show="showAdd " title="客户信息" @cancel="closeDlg" :showCancelButton="true" @confirm="doAddUser">
  29. <view class="slot-content">
  30. <u--form labelPosition="left" :model="model1" ref="s">
  31. <u-form-item label="客户名称:" prop="chooseUser.deptName" borderBottom ref="item1" labelWidth="auto">
  32. <u--input v-model="chooseUser.deptName" border="none"></u--input>
  33. </u-form-item>
  34. <u-form-item label="联系人:" prop="chooseUser.nickName" borderBottom ref="item1" labelWidth="auto">
  35. <u--input v-model="chooseUser.nickName" border="none"></u--input>
  36. </u-form-item>
  37. <u-form-item label="手机号:" prop="chooseUser.phonenumber" borderBottom ref="item1" labelWidth="auto">
  38. <u--input v-model="chooseUser.phonenumber" border="none"></u--input>
  39. </u-form-item>
  40. <u-form-item label="密码:" prop="chooseUser.password" borderBottom ref="item1" labelWidth="auto">
  41. <u--input v-if="showAdd" v-model="chooseUser.password" border="none"></u--input>
  42. </u-form-item>
  43. <u-form-item label="登录账号:" borderBottom ref="item1" labelWidth="auto">
  44. <u--input v-model="chooseUser.phonenumber" border="none" disabled></u--input>
  45. </u-form-item>
  46. <u-form-item label="状态:" prop="chooseUser.password" borderBottom ref="item1" labelWidth="auto">
  47. <u-radio-group v-model="statusValue" placement="row">
  48. <u-radio v-for="(item, index) in statusList" :key="index" :label="item.name"
  49. :name="item.name" @change="statusChange">
  50. </u-radio>
  51. </u-radio-group>
  52. </u-form-item>
  53. <u-form-item label="显示排序:" prop="chooseUser.orderNum" borderBottom ref="item1" labelWidth="auto">
  54. <uni-number-box v-model="chooseUser.orderNum" />
  55. </u-form-item>
  56. </u--form>
  57. </view>
  58. </u-modal>
  59. </view>
  60. </template>
  61. <script>
  62. import authObj from '@/plugins/auth.js';
  63. import {
  64. getDeptList,
  65. getUserListByDept
  66. } from '@/api/user/user';
  67. import {
  68. addDeptAndUser,
  69. delDept
  70. } from '@/api/dept/dept'
  71. import {
  72. unbind
  73. } from '@/api/device/device.js'
  74. import UText from "../../uni_modules/uview-ui/components/u-text/u-text";
  75. import {
  76. checkStr
  77. } from "@/utils/validate.js"
  78. export default {
  79. components: {
  80. UText
  81. },
  82. data() {
  83. return {
  84. deptList: [],
  85. search: {
  86. deptName: ""
  87. },
  88. statusList: [{
  89. name: '启用',
  90. disabled: false
  91. },
  92. {
  93. name: '禁用',
  94. disabled: false
  95. }
  96. ],
  97. statusValue: '启用',
  98. //showEdit: false,
  99. showAdd: false,
  100. chooseUser: {},
  101. }
  102. },
  103. onLoad() {
  104. this.getDeptList();
  105. },
  106. methods: {
  107. newUser() {
  108. this.showAdd = true;
  109. this.chooseUser.orderNum = 1
  110. },
  111. closeDlg() {
  112. console.log('closeDlg>>>>>>>')
  113. this.showAdd = false;
  114. this.chooseUser = {};
  115. },
  116. statusChange(e) {
  117. console.log(e);
  118. },
  119. searchDept() {
  120. this.getDeptList();
  121. },
  122. toUser(item) {
  123. uni.navigateTo({
  124. url: '/pages/user/list?deptId=' + item.deptId
  125. });
  126. },
  127. toDeviceList(item) {
  128. uni.navigateTo({
  129. url: '/pages/device/index?deptId=' + item.deptId
  130. });
  131. },
  132. //删除客户,并删除客户下的用户信息和解绑设备
  133. toDel(item){
  134. let self=this
  135. uni.showModal({
  136. title: '提示',
  137. content: "删除客户信息并解绑设备?",
  138. confirmText:'取消',
  139. confirmColor:'#2979ff',
  140. cancelText:'确定',
  141. cancelColor:'#ed1c24',
  142. success: function (res) {
  143. if (res.confirm) {
  144. console.log('取消'+JSON.stringify(item));
  145. } else if (res.cancel) {
  146. console.log('用户点击确定'+JSON.stringify(item));
  147. unbind(item.deptId).then(res=>{
  148. uni.showToast({
  149. title: '操作成功',
  150. icon: 'none',
  151. duration: 1500
  152. })
  153. location.reload()
  154. })
  155. }
  156. }
  157. });
  158. },
  159. getDeptList() {
  160. getDeptList(this.search.deptName).then(res => {
  161. this.deptList = res.data;
  162. });
  163. },
  164. doAddUser() {
  165. let self = this;
  166. this.chooseUser.postIds = [];
  167. if (this.statusValue == '启用') {
  168. this.chooseUser.status = 0;
  169. } else {
  170. this.chooseUser.status = 1;
  171. }
  172. if (!checkStr(this.chooseUser.phonenumber, 'mobile')) {
  173. uni.showToast({
  174. title: '手机号码格式有误',
  175. icon: 'none',
  176. duration: 1000
  177. })
  178. } else {
  179. this.chooseUser.userName = this.chooseUser.phonenumber
  180. if (this.showAdd) {
  181. addDeptAndUser(this.chooseUser).then(res => {
  182. uni.showToast({
  183. title: '操作成功',
  184. icon: 'none',
  185. duration: 1500
  186. })
  187. self.closeDlg();
  188. location.reload()
  189. }).catch(res => {
  190. console.log('close>>>>>>erro')
  191. })
  192. }
  193. }
  194. },
  195. }
  196. }
  197. </script>
  198. <style lang="scss">
  199. /* #ifndef APP-NVUE */
  200. .u-collapse-content {
  201. display: flex;
  202. flex-direction: column;
  203. }
  204. page {
  205. display: flex;
  206. flex-direction: column;
  207. box-sizing: border-box;
  208. background-color: #fff;
  209. min-height: 100%;
  210. height: auto;
  211. }
  212. view {
  213. font-size: 14px;
  214. line-height: inherit;
  215. }
  216. /* #endif */
  217. .text {
  218. text-align: center;
  219. font-size: 26rpx;
  220. margin-top: 10rpx;
  221. }
  222. .grid-item-box {
  223. flex: 1;
  224. /* #ifndef APP-NVUE */
  225. display: flex;
  226. /* #endif */
  227. flex-direction: column;
  228. align-items: center;
  229. justify-content: center;
  230. padding: 15px 0;
  231. }
  232. .uni-margin-wrap {
  233. width: 690rpx;
  234. width: 100%;
  235. ;
  236. }
  237. .swiper {
  238. height: 300rpx;
  239. }
  240. .swiper-box {
  241. height: 150px;
  242. }
  243. .swiper-item {
  244. /* #ifndef APP-NVUE */
  245. display: flex;
  246. /* #endif */
  247. flex-direction: column;
  248. justify-content: center;
  249. align-items: center;
  250. color: #fff;
  251. height: 300rpx;
  252. line-height: 300rpx;
  253. }
  254. @media screen and (min-width: 500px) {
  255. .uni-swiper-dot-box {
  256. width: 400px;
  257. /* #ifndef APP-NVUE */
  258. margin: 0 auto;
  259. /* #endif */
  260. margin-top: 8px;
  261. }
  262. .image {
  263. width: 100%;
  264. }
  265. }
  266. </style>