index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <div id="device-management">
  3. <div class="device-management-body" v-loading.fullscreen.lock="fullscreenLoading">
  4. <div class="order-management-body">
  5. <div class="order-management-inner">
  6. <div class="base-info">
  7. <!-- <span>关键词:</span> -->
  8. <span>用户名:</span>
  9. <el-input style="width:220px;" @keyup.enter.native="currentPage=1&&_getCameraData()" v-model="searchKey" placeholder="请输入用户名"></el-input>
  10. <el-button type="primary" @click="currentPage=1&&_getCameraData()" color='red'>搜索</el-button>
  11. <el-button icon="el-icon-plus" type="primary" style="float: right;" @click="showCameraDialog" color='red'>添加相机</el-button>
  12. </div>
  13. </div>
  14. <!-- 全部 -->
  15. <div class="device-management_bottom">
  16. <div class="order-management-table">
  17. <el-table ref="order_table" class='e-table' :data="cameras" style="width: 100%">
  18. <el-table-column prop="childName" label="设备ID">
  19. </el-table-column>
  20. <el-table-column prop="userName" label="手机号(用户名)">
  21. </el-table-column>
  22. <el-table-column prop="goodsName" label="设备类型">
  23. </el-table-column>
  24. <el-table-column prop="snCode" label="sn码">
  25. </el-table-column>
  26. <el-table-column width="300" label="激活时间">
  27. <template slot-scope="scope">
  28. <div>{{scope.row.activatedTime}}</div>
  29. </template>
  30. </el-table-column>
  31. <el-table-column prop="own" label="出货类型">
  32. </el-table-column>
  33. <el-table-column prop="companyName" label="客户名称">
  34. <template slot-scope="scope">
  35. <div>{{scope.row.companyName||'-'}}</div>
  36. </template>
  37. </el-table-column>
  38. <el-table-column prop="balance" label="当前余额(点)">
  39. </el-table-column>
  40. <el-table-column label="操作">
  41. <template slot-scope="scope">
  42. <el-button type="text" @click="showDialog(scope.row)" class="edit_btn">点数</el-button>
  43. <el-button type="text" v-if="scope.row.userName!='未绑定'" @click="_unbindDevice(scope.row)" class="delete_btn">解绑</el-button>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. </div>
  48. <div class="order-management-pagination">
  49. <el-pagination @current-change="handleCurrentChange" :current-page.sync="currentPage" :page-size="pagesize" layout="total, prev, pager, next, jumper" :total="total">
  50. </el-pagination>
  51. </div>
  52. </div>
  53. <el-dialog width="450px" title="点数修改" :visible.sync="dialogFormVisible">
  54. <el-form :model="form" >
  55. <el-form-item >
  56. <div style="display: flex;justify-content: space-between;font-size: 14px;">
  57. <span>设备ID:
  58. <span>{{currentChildName}}</span>
  59. </span>
  60. <span>当前余额:
  61. <span>{{currentBalance}}</span>
  62. </span>
  63. </div>
  64. </el-form-item>
  65. <el-form-item label="充值类型">
  66. <el-select v-model="form.region" placeholder="请选择点数修改类型">
  67. <el-option label="系统赠送" value=0></el-option>
  68. <el-option label="退充值款" value=-2></el-option>
  69. </el-select>
  70. </el-form-item>
  71. <el-form-item label="充值点数" width="100%">
  72. <el-input @keyup.native="_checkInput" maxlength="5" :suffix-icon="form.region==-2?'el-icon-minus':'el-icon-plus'" v-model.number="form.point"></el-input>
  73. </el-form-item>
  74. </el-form>
  75. <div slot="footer" class="dialog-footer">
  76. <el-button @click="dialogFormVisible = false">取 消</el-button>
  77. <el-button type="primary" @click="_modifyPoints">确 定</el-button>
  78. </div>
  79. </el-dialog>
  80. <el-dialog width="470px" title="添加相机" :visible.sync="cameraVisible">
  81. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px">
  82. <el-form-item label="出库类型" prop="own">
  83. <el-select v-model="ruleForm.own" placeholder="请选择出库类型">
  84. <el-option label="正常销售" value="0"></el-option>
  85. <el-option label="礼品赠送" value="2"></el-option>
  86. <el-option label="员工自用" value="1"></el-option>
  87. <el-option label="其他" value="3"></el-option>
  88. </el-select>
  89. </el-form-item>
  90. <el-form-item label="相机类型" prop="type">
  91. <el-select v-model="ruleForm.type" placeholder="请选择相机类型">
  92. <el-option label="四维看看Pro八目相机" value="1"></el-option>
  93. <el-option label="四维看看Lite双目相机" value="0"></el-option>
  94. <el-option label="四维看看双目转台相机" value="3"></el-option>
  95. <el-option label="四维看看激光相机" value="4"></el-option>
  96. </el-select>
  97. </el-form-item>
  98. <el-form-item label="wifi名称" prop="wifi">
  99. <el-input v-model="ruleForm.wifi"></el-input>
  100. </el-form-item>
  101. <el-form-item label="物理地址" prop="address">
  102. <el-input v-model="ruleForm.address"></el-input>
  103. </el-form-item>
  104. <el-form-item label="sn码" prop="snCode">
  105. <el-input v-model="ruleForm.snCode"></el-input>
  106. </el-form-item>
  107. <el-form-item label="初始点数" @keyup.native="_checkPointInput" prop="initPoint">
  108. <el-input v-model="ruleForm.initPoint"></el-input>
  109. </el-form-item>
  110. <el-form-item label="订单号" prop="orderNum">
  111. <el-input v-model="ruleForm.orderNum"></el-input>
  112. </el-form-item>
  113. <el-form-item label="客户名称" prop="own">
  114. <el-select v-model="ruleForm.companyId" placeholder="请选择">
  115. <el-option v-for="(item,i) in companyList" :key="i" :label="item.companyName" :value="item.id">{{item.companyName}}</el-option>
  116. </el-select>
  117. </el-form-item>
  118. </el-form>
  119. <div slot="footer" class="dialog-footer">
  120. <el-button @click="cameraVisible = false">取 消</el-button>
  121. <el-button type="primary" @click="_addCamera">确 定</el-button>
  122. </div>
  123. </el-dialog>
  124. </div>
  125. </div>
  126. </div>
  127. </template>
  128. <script>
  129. export default {
  130. data () {
  131. return {
  132. tabs: [{ name: '设备ID', idx: 0 }, { name: '手机号', idx: 1 }, { name: '当前余额', idx: 2 }, { name: '历史充值', idx: 3 }],
  133. expands: [],
  134. expandedArr: [],
  135. cameras: [],
  136. currentPage: 1,
  137. key_input: '',
  138. fullscreenLoading: false,
  139. product: {
  140. 'name': '',
  141. 'packageName': '',
  142. 'count': '',
  143. 'amount': '',
  144. 'url': ''
  145. },
  146. // labelPosition: 'right',
  147. receive: {
  148. 'name': '',
  149. 'phone': '',
  150. 'address': '',
  151. 'invoice': '',
  152. 'expressNum': ''
  153. },
  154. searchKey: '',
  155. total: 0,
  156. // expressNum_input: "",
  157. searchDate: [],
  158. searchOrderNumber: '',
  159. searchPhone: '',
  160. searchExpressNum: '',
  161. hasClickSearch: false,
  162. tabIndex: 0,
  163. dialogFormVisible: false,
  164. cameraVisible: false,
  165. form: {
  166. point: '',
  167. region: '',
  168. date1: '',
  169. date2: '',
  170. delivery: false,
  171. type: [],
  172. resource: '',
  173. desc: ''
  174. },
  175. ruleForm: {
  176. wifi: '',
  177. address: '',
  178. initPoint: '',
  179. type: [],
  180. own: [],
  181. snCode: '',
  182. orderNum: '',
  183. companyId: ''
  184. },
  185. rules: {
  186. wifi: [
  187. { required: true, message: '请输入WiFi名称', trigger: 'blur' }
  188. // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
  189. ],
  190. address: [
  191. { required: true, message: '请输入物理地址', trigger: 'blur' }
  192. // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
  193. ],
  194. snCode: [
  195. { required: true, message: '请输入SN码', trigger: 'blur' }
  196. // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
  197. ],
  198. initPoint: [
  199. { required: true, message: '请输入初始点数', trigger: 'blur' }
  200. // { type: "number", message: '必须为数字值', trigger: 'blur' }
  201. ]
  202. },
  203. cameraInfo: {
  204. wifi: '',
  205. type: '',
  206. address: '',
  207. initPoint: '',
  208. orderNum: '',
  209. companyId: ''
  210. },
  211. companyList: [],
  212. formLabelWidth: '30%',
  213. value2: true,
  214. currentChildName: '',
  215. currentDeviceId: '',
  216. currentBalance: '',
  217. pagesize: 10
  218. }
  219. },
  220. watch: {
  221. currentPage () {
  222. this._getCameraData()
  223. }
  224. },
  225. methods: {
  226. _getCameraData () {
  227. this.fullscreenLoading = true
  228. if (!Number(this.currentPage)) this.currentPage = 1
  229. let params = {
  230. userName: window.localStorage.getItem('zfb_username')
  231. }
  232. this.$http({
  233. method:'post',
  234. url:'/company/selectCompanyDevice',
  235. data: params,
  236. headers:{
  237. token: window.localStorage.getItem('zfb_token')
  238. }
  239. }).then(res => {
  240. this.fullscreenLoading = false
  241. console.log(res)
  242. if (res.code === 0) {
  243. let temp = res.data.list
  244. // let temp = res.message
  245. for (var i = 0; i < temp.length; i++) {
  246. switch (temp[i]['own']) {
  247. case 0:
  248. temp[i]['own'] = '正常销售'
  249. break
  250. case 1:
  251. temp[i]['own'] = '员工自用'
  252. break
  253. case 2:
  254. temp[i]['own'] = '礼品赠送'
  255. break
  256. case 3:
  257. temp[i]['own'] = '其他'
  258. break
  259. }
  260. temp[i]['userName'] = temp[i]['userName'] ? temp[i]['userName'] : '未绑定'
  261. temp[i]['activatedTime'] = temp[i]['activatedTime'] ? new Date(temp[i]['activatedTime']).format('yyyy-MM-dd hh:mm:ss') : '/'
  262. }
  263. this.cameras = temp
  264. this.total = res.data.total ? res.data.total : this.total
  265. }
  266. })
  267. },
  268. handleCurrentChange (val) {
  269. this.currentPage = val
  270. },
  271. showDialog (row) {
  272. this.form.region = ''
  273. this.form.point = ''
  274. this.currentChildName = row.childName
  275. this.currentDeviceId = row.id
  276. this.currentBalance = row.balance
  277. this.dialogFormVisible = true
  278. },
  279. async getCompanyList () {
  280. let result = await this.$http.post('/manager/company/listAll')
  281. this.companyList = result.data
  282. },
  283. async _unbindDevice (row) {
  284. this.$confirm('确定把该设备从账号中解除绑定', '解绑设备', {
  285. confirmButtonText: '确定',
  286. cancelButtonText: '取消',
  287. type: 'warning'
  288. }).then(async () => {
  289. this.fullscreenLoading = true
  290. console.log(row)
  291. let res = await this.$http.post('/manager/camera/unbind', {
  292. cameraId: row.id
  293. })
  294. if (res.code === 0) {
  295. this.$message({
  296. type: 'success',
  297. message: '解绑成功!'
  298. })
  299. this._getCameraData()
  300. } else {
  301. this.$alert('解绑失败', '提示', {
  302. confirmButtonText: '确定'
  303. })
  304. }
  305. this.fullscreenLoading = false
  306. }).catch(() => {
  307. this.$message({
  308. type: 'info',
  309. message: '已取消解绑'
  310. })
  311. this.fullscreenLoading = false
  312. })
  313. },
  314. _checkInput: function (e) {
  315. this.form.point += ''
  316. this.form.point = this.form.point.replace(/[^\d]/g, '')
  317. if (Number(this.form.point) && this.form.point > 10000) {
  318. this.form.point = 10000
  319. }
  320. },
  321. _checkPointInput: function (e) {
  322. this.ruleForm.initPoint += ''
  323. this.ruleForm.initPoint = this.ruleForm.initPoint.replace(/[^\d]/g, '')
  324. if (Number(this.ruleForm.initPoint) && this.ruleForm.initPoint > 10000) {
  325. this.ruleForm.initPoint = 10000
  326. }
  327. },
  328. async _modifyPoints () {
  329. let body = this.form.region
  330. let points = this.form.point
  331. let cameraId = this.currentDeviceId
  332. if (!body) {
  333. this.$alert('请选择充值类型', '提示', {
  334. confirmButtonText: '确定',
  335. callback: action => {
  336. }
  337. })
  338. } else {
  339. let res = await this.$http.post('/manager/camera/modifyPoints', {
  340. body: Number(body),
  341. cameraId,
  342. points
  343. })
  344. if (res.code === 0) {
  345. this.$message({
  346. type: 'success',
  347. message: '充值成功!'
  348. })
  349. this._getCameraData()
  350. this.dialogFormVisible = false
  351. } else {
  352. this.$alert(res.msg, '提示', {
  353. confirmButtonText: '确定'
  354. })
  355. }
  356. }
  357. },
  358. async _addCamera () {
  359. let {
  360. wifi: wifiName,
  361. address: childName,
  362. initPoint: balance,
  363. own,
  364. type,
  365. snCode,
  366. companyId,
  367. orderNum: orderSn
  368. } = this.ruleForm
  369. if (wifiName === '' || childName === '' || snCode === '' || balance === '' || own === '' || type === '') {
  370. return
  371. }
  372. this.fullscreenLoading = true
  373. let res = await this.$http.post('/manager/camera/add', {
  374. childName,
  375. wifiName,
  376. orderSn,
  377. snCode,
  378. companyId,
  379. balance: Number(balance),
  380. type: Number(type),
  381. own
  382. })
  383. this.fullscreenLoading = false
  384. if (res.code === 0) {
  385. this.$alert('该相机信息已成功添加入库', '添加成功', {
  386. confirmButtonText: '确定'
  387. })
  388. this._getCameraData()
  389. this.ruleForm.address = ''
  390. this.ruleForm.wifi = ''
  391. this.ruleForm.own = ''
  392. this.ruleForm.orderNum = ''
  393. this.ruleForm.snCode = ''
  394. this.ruleForm.type = ''
  395. this.ruleForm.initPoint = ''
  396. this.ruleForm.companyId = ''
  397. this.cameraVisible = false
  398. } else {
  399. this.$alert(res.msg, '添加失败', {
  400. confirmButtonText: '确定'
  401. })
  402. }
  403. },
  404. showCameraDialog (row) {
  405. this.cameraVisible = true
  406. }
  407. },
  408. created () {
  409. this._getCameraData()
  410. this.getCompanyList()
  411. }
  412. }
  413. </script>
  414. <style lang="css" scoped>
  415. @import './style.css';
  416. </style>
  417. <style type="text/css">
  418. .el-table__expand-icon>i {
  419. display: none !important;
  420. }
  421. .edit_btn span {
  422. color: #09e1c0
  423. }
  424. .delete_btn span {
  425. color: #f56c6c
  426. }
  427. </style>