index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. <template slot-scope="scope">
  2. <div class="con" v-loading.fullscreen.lock="loading">
  3. <el-dialog width="470px" title="添加相机" :visible.sync="cameraVisible" :show-close="false" :close-on-click-modal="false">
  4. <el-form label-width="80px" :rules="rules" :model="ruleForm">
  5. <el-form-item label="出库类型" prop="own">
  6. <el-select v-model="ruleForm.own" placeholder="请选择出库类型">
  7. <el-option label="正常销售" value="0"></el-option>
  8. <el-option label="礼品赠送" value="2"></el-option>
  9. <el-option label="员工自用" value="1"></el-option>
  10. <el-option label="其他" value="3"></el-option>
  11. </el-select>
  12. </el-form-item>
  13. <el-form-item label="相机类型" prop="cameraType">
  14. <el-select v-model="ruleForm.cameraType" placeholder="请选择相机类型">
  15. <el-option label="四维看看Pro八目相机" value="4"></el-option>
  16. <el-option label="四维看看Lite双目相机" value="1"></el-option>
  17. <el-option label="四维看看双目转台相机" value="9"></el-option>
  18. <el-option label="四维看看激光相机" value="10"></el-option>
  19. <el-option label="第三方相机" value="6"></el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="设备ID" prop="childName">
  23. <el-input v-model="ruleForm.childName"></el-input>
  24. </el-form-item>
  25. <el-form-item label="wifi名称" prop="wifiName">
  26. <el-input v-model="ruleForm.wifiName"></el-input>
  27. </el-form-item>
  28. <el-form-item label="物理地址" prop="address">
  29. <el-input v-model="ruleForm.address"></el-input>
  30. </el-form-item>
  31. <el-form-item
  32. v-if="ruleForm.cameraType != '' && ruleForm.cameraType != 6"
  33. label="sn码" prop="snCode"
  34. >
  35. <el-input v-model="ruleForm.snCode"></el-input>
  36. </el-form-item>
  37. <el-form-item label="初始点数" prop="balance">
  38. <el-input v-model="ruleForm.balance"></el-input>
  39. </el-form-item>
  40. <el-form-item label="订单号" prop="orderSn">
  41. <el-input v-model="ruleForm.orderSn"></el-input>
  42. </el-form-item>
  43. <el-form-item label="客户名称" prop="compantId">
  44. <el-select v-model="ruleForm.companyId" placeholder="请选择">
  45. <el-option
  46. v-for="(item, i) in companyList"
  47. :key="i"
  48. :label="item.name"
  49. :value="item.id"
  50. >{{ item.name }}</el-option
  51. >
  52. </el-select>
  53. </el-form-item>
  54. </el-form>
  55. <div slot="footer" class="dialog-footer">
  56. <el-button @click="clearData">取 消</el-button>
  57. <el-button type="primary" @click="addCamera">确 定</el-button>
  58. </div>
  59. </el-dialog>
  60. <div class="h-header">
  61. <vcenter>
  62. <div class="h-input">
  63. <el-input v-model="userName" placeholder="请输入用户名"></el-input>
  64. </div>
  65. <div>
  66. <el-button type="primary" @click="getData">搜索</el-button>
  67. </div>
  68. <div style="float: right; padding-right: 20px">
  69. <el-button type="primary" @click="cameraVisible = true"
  70. >添加相机</el-button
  71. >
  72. </div>
  73. <!-- <div style="float:right;padding-right:50px">
  74. <el-button type="primary" @click="ShebeiVisible = true">添加设备</el-button>
  75. </div> -->
  76. </vcenter>
  77. </div>
  78. <div class="h-body">
  79. <el-table
  80. height="520"
  81. :data="tableData"
  82. style="width: 100%; padding: 0 20px"
  83. >
  84. <el-table-column
  85. v-for="(item, i) in tableHeader"
  86. :key="i"
  87. :prop="item.name"
  88. :label="item.label"
  89. >
  90. </el-table-column>
  91. <!-- <el-table-column label="操作">
  92. <template slot-scope="scope">
  93. <div>
  94. <span>点数</span>
  95. <span>解绑</span>
  96. </div>
  97. </template>
  98. </el-table-column> -->
  99. </el-table>
  100. <div class="p-con">
  101. <el-pagination
  102. @current-change="handleCurrentChange"
  103. :current-page.sync="currentPage"
  104. :page-size="size"
  105. layout="total, prev, pager, next, jumper"
  106. :total="total"
  107. ></el-pagination>
  108. </div>
  109. </div>
  110. </div>
  111. </template>
  112. <script>
  113. import vcenter from "@/components/vcenter";
  114. export default {
  115. components: { vcenter },
  116. data() {
  117. return {
  118. c_userName: "",
  119. loading: false,
  120. currentPage: 1,
  121. size: 10,
  122. total: 0,
  123. userName: "",
  124. companyList: [],
  125. childName: "",
  126. tableData: [],
  127. tableHeader: [
  128. { name: "childName", label: "设备ID" },
  129. { name: "userName", label: "手机号(用户名)" },
  130. // { name: "goodsName", label: "设备类型" },
  131. { name: "cameraType", label: "设备类型" },
  132. { name: "snCode", label: "sn码" },
  133. { name: "wifiName", label: "wifi"},
  134. { name: "activatedTime", label: "激活时间" },
  135. { name: "own", label: "出货类型" },
  136. { name: "companyName", label: "客户名称" },
  137. { name: "balance", label: "当前余额(点)" },
  138. ],
  139. // ShebeiVisible: false,
  140. cameraVisible: false,
  141. ruleForm: {
  142. wifiName: "",
  143. address: "",
  144. // initPoint: "",
  145. balance:"",
  146. cameraType: [],
  147. own: [],
  148. snCode: "",
  149. orderSn: "",
  150. companyId: "",
  151. childName:""
  152. },
  153. rules:{
  154. snCode: [{ required:true ,message:'sn码不能为空'}],
  155. own: [{required: true, message:'出库类型不能为空'}],
  156. cameraType: [{required: true, message:'相机类型不能为空'}],
  157. childName: [{required: true, message:'设备ID不能为空', trigger: 'blur'}],
  158. wifiName: [{required: true, message:'wifi名称不能为空', trigger: 'blur'}],
  159. address: [{required: true, message:'物理地址不能为空', trigger: 'blur'}],
  160. balance: [{required: true, message:'初始点数不能为空', trigger: 'blur'}],
  161. orderSn: [{required: true, message:'订单号不能为空', trigger: 'blur'}],
  162. companyId: [{required: true, message:'客户名称不能为空', trigger: 'blur'}]
  163. },
  164. // addEq: {
  165. // userName: "",
  166. // companyId: "",
  167. // shebeiNum: "",
  168. // shebeiId: "",
  169. // },
  170. addDevies: [
  171. {
  172. value: "",
  173. isAvailable: false,
  174. hasCheck: false,
  175. },
  176. ],
  177. errMsg: "",
  178. num: "",
  179. };
  180. },
  181. methods: {
  182. // handleSizeChange(val) {
  183. // console.log(`每页 ${val} 条`);
  184. // },
  185. // handleCurrentChange(val) {
  186. // console.log(`当前页: ${val}`);
  187. // },
  188. getData() {
  189. if (!Number(this.currentPage)) this.currentPage = 1;
  190. let params = {
  191. userName: this.userName || "",
  192. };
  193. this.$http({
  194. method: "post",
  195. data: params,
  196. url: "/camera/pageList",
  197. headers: {
  198. token: window.localStorage.getItem("zfb_token"),
  199. pageNum: this.currentPage,
  200. pageSize: this.size,
  201. },
  202. }).then((res) => {
  203. for(let i=0;i<res.message.list.length;i++){
  204. res.message.list[i].activatedTime = this.$base.dateFormat('yyyy-MM-dd hh:mm',new Date(res.message.list[i].activatedTime))
  205. res.message.list[i].own = this.ownToName(res.message.list[i].own)
  206. res.message.list[i].cameraType = this.typeToName(res.message.list[i].cameraType)
  207. }
  208. this.tableData = res.message.list;
  209. this.total = res.message.total;
  210. this.currentPage = res.message.pageNum
  211. });
  212. },
  213. addCamera() {
  214. if (this.ruleForm.cameraType != 6 && this.ruleForm.snCode == "") {
  215. this.$alert("sn码不能为空!", "提示", {
  216. confirmButtonText: "确定",
  217. });
  218. return;
  219. }
  220. let params = {
  221. wifiName: this.ruleForm.wifiName,
  222. address: this.ruleForm.address,
  223. // initPoint: this.ruleForm.initPoint,
  224. balance: this.ruleForm.balance,
  225. cameraType: this.ruleForm.cameraType,
  226. own: this.ruleForm.own,
  227. snCode: this.ruleForm.snCode,
  228. orderSn: this.ruleForm.orderSn,
  229. companyId: this.ruleForm.companyId,
  230. childName: this.ruleForm.childName
  231. };
  232. this.$http({
  233. method: "post",
  234. url: "/camera/add",
  235. data: params,
  236. headers: {
  237. token: window.localStorage.getItem("zfb_token"),
  238. pageNum: this.currentPage,
  239. pageSize: this.size,
  240. },
  241. }).then((res) => {
  242. if (res.code === 200) {
  243. this.$alert("相机添加成功", "提示", {
  244. confirmButtonText: "确定",
  245. callback: (action) => {
  246. this.getCompanyList();
  247. this.ruleForm = {
  248. wifiName: "",
  249. address: "",
  250. // initPoint: "",
  251. balance:"",
  252. cameraType: [],
  253. own: [],
  254. snCode: "",
  255. orderSn: "",
  256. companyId: "",
  257. childName:""
  258. }
  259. this.cameraVisible = false;
  260. this.refresh()
  261. },
  262. });
  263. } else {
  264. this.$alert("相机添加失败", "提示", {
  265. confirmButtonText: "确定",
  266. callback: (action) => {},
  267. });
  268. }
  269. });
  270. },
  271. clearData(){
  272. this.cameraVisible = false
  273. this.ruleForm = {
  274. wifiName: "",
  275. address: "",
  276. // initPoint: "",
  277. balance:"",
  278. cameraType: [],
  279. own: [],
  280. snCode: "",
  281. orderSn: "",
  282. companyId: "",
  283. childName:""
  284. }
  285. },
  286. ownToName(own){
  287. switch(own){
  288. case 0:
  289. return "正常销售"
  290. break
  291. case 2:
  292. return "礼品赠送"
  293. break
  294. case 1:
  295. return "员工自用"
  296. break
  297. case 3:
  298. return "其它"
  299. break
  300. }
  301. },
  302. typeToName(cameraType){
  303. switch(cameraType){
  304. case 4:
  305. return "四维看看Pro八目相机"
  306. break
  307. case 1:
  308. return "四维看看Lite双目相机"
  309. break
  310. case 9:
  311. return "四维看看双目转台相机"
  312. break
  313. case 10:
  314. return "四维看看激光相机"
  315. break
  316. case 6:
  317. return "第三方相机"
  318. break
  319. }
  320. },
  321. async getCompanyList() {
  322. let result = await this.$http.post("/company/listAll");
  323. this.companyList = result.message;
  324. },
  325. handleCurrentChange(val) {
  326. this.currentPage = val;
  327. },
  328. refresh() {
  329. this.loading = true;
  330. this.getData();
  331. this.loading = false;
  332. },
  333. // search() {
  334. // this.currentPage === 1 ? this.refresh() : (this.currentPage = 1);
  335. // this.getData()
  336. // },
  337. checkLegal(item) {
  338. if (item.value) {
  339. let params = {
  340. childName: item.value,
  341. };
  342. this.$http({
  343. method: "post",
  344. data: params,
  345. url: "/company/checkDevice",
  346. headers: {
  347. token: window.localStorage.getItem("zfb_token"),
  348. },
  349. }).then((res) => {
  350. if (res.code === 200) {
  351. item.isAvailable = true;
  352. } else {
  353. item.isAvailable = false;
  354. this.errMsg = "该ID不可用";
  355. }
  356. item.hasCheck = true;
  357. });
  358. } else {
  359. item.isAvailable = false;
  360. item.hasCheck = true;
  361. this.errMsg = "ID不能为空";
  362. }
  363. },
  364. },
  365. mounted() {
  366. this.getCompanyList();
  367. console.log("mounted");
  368. this.refresh();
  369. },
  370. watch: {
  371. currentPage() {
  372. this.getData();
  373. },
  374. // size() {
  375. // this.refresh();
  376. // },
  377. num(newVal, oldVal) {
  378. if (newVal > oldVal) {
  379. this.addDevies.push({
  380. value: "",
  381. isAvailable: false,
  382. hasCheck: false,
  383. });
  384. } else {
  385. this.addDevies.pop();
  386. }
  387. },
  388. },
  389. };
  390. </script>
  391. <style lang="scss" scoped>
  392. .con {
  393. .time-data {
  394. position: relative;
  395. .select-data {
  396. position: absolute;
  397. left: 0;
  398. top: 0;
  399. opacity: 0;
  400. cursor: pointer;
  401. }
  402. > span {
  403. color: #0175dc;
  404. }
  405. }
  406. .ei-num {
  407. .el-input-number {
  408. width: 90%;
  409. }
  410. }
  411. .clear-music {
  412. position: relative;
  413. text-align: right;
  414. top: -30px;
  415. color: #999;
  416. cursor: pointer;
  417. }
  418. .musicIcon {
  419. width: 100%;
  420. height: 100%;
  421. line-height: 1;
  422. margin-top: 35px;
  423. img {
  424. width: 50px;
  425. height: auto;
  426. }
  427. p {
  428. font-weight: bold;
  429. font-size: 14px;
  430. color: #000;
  431. line-height: 20px;
  432. height: 20px;
  433. margin-top: 20px;
  434. }
  435. }
  436. .icon-plus {
  437. margin-left: 15px;
  438. width: 40px;
  439. height: 38px;
  440. line-height: 38px;
  441. text-align: center;
  442. background: #f5f7fa;
  443. color: #999;
  444. cursor: pointer;
  445. font-size: 13px;
  446. display: inline-block;
  447. border: 1px solid #dcdfe6;
  448. border-radius: 4px;
  449. &:hover {
  450. border: 1px solid #c0c4cc;
  451. }
  452. }
  453. .add-num {
  454. margin-left: 15px;
  455. width: 250px;
  456. .icon-close,
  457. .icon-correct {
  458. line-height: 1;
  459. color: #999;
  460. }
  461. input[type="number"]::-webkit-inner-spin-button,
  462. input[type="number"]::-webkit-outer-spin-button {
  463. -webkit-appearance: none;
  464. margin: 0;
  465. }
  466. }
  467. .ei-input {
  468. width: 100%;
  469. max-height: 200px;
  470. overflow-y: auto;
  471. .input-con {
  472. display: inline-block;
  473. width: 45%;
  474. margin: 2px 5px 2px 0;
  475. height: 60px;
  476. position: relative;
  477. .el-input_err {
  478. & /deep/ .el-input__inner {
  479. border: 1px solid #f56c6c;
  480. }
  481. }
  482. .el-input_success {
  483. & /deep/ .el-input__inner {
  484. border: 1px solid #67c23a;
  485. }
  486. }
  487. span {
  488. color: #f56c6c;
  489. font-size: 12px;
  490. line-height: 1;
  491. padding-top: 4px;
  492. position: absolute;
  493. left: 0;
  494. }
  495. }
  496. }
  497. .h-header {
  498. height: 80px;
  499. background-color: #fff;
  500. padding-left: 20px;
  501. box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
  502. border-radius: 3px;
  503. div {
  504. display: inline-block;
  505. }
  506. .h-input {
  507. width: 220px;
  508. }
  509. }
  510. .h-body {
  511. width: 100%;
  512. margin: 30px 0 0;
  513. padding-top: 20px;
  514. box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
  515. border-radius: 3px;
  516. background-color: #fff;
  517. .logo-add {
  518. div {
  519. cursor: pointer;
  520. line-height: 40px;
  521. border: 1px dotted #dcdfe6;
  522. border-radius: 4px;
  523. font-weight: bold;
  524. font-size: 18px;
  525. display: inline-block;
  526. width: 40px;
  527. height: 40px;
  528. background: #f5f7fa;
  529. position: relative;
  530. img {
  531. width: 100%;
  532. height: 100%;
  533. position: absolute;
  534. top: 0;
  535. left: 0;
  536. }
  537. span {
  538. position: absolute;
  539. z-index: 100;
  540. left: 0;
  541. top: 0;
  542. width: 100%;
  543. height: 100%;
  544. }
  545. }
  546. }
  547. .o-span {
  548. color: #0175dc;
  549. cursor: pointer;
  550. }
  551. .p-con {
  552. width: 100%;
  553. text-align: right;
  554. padding: 25px 20px 30px;
  555. }
  556. }
  557. .d-table {
  558. border: 1px solid #ccc;
  559. .d-con {
  560. max-height: 200px;
  561. overflow-y: scroll;
  562. }
  563. .d-header {
  564. font-weight: bold;
  565. }
  566. .d-header,
  567. .d-body {
  568. height: 40px;
  569. line-height: 40px;
  570. width: 100%;
  571. border-bottom: 1px solid #ccc;
  572. &:last-child {
  573. border: none;
  574. }
  575. span {
  576. text-align: center;
  577. display: inline-block;
  578. width: 24%;
  579. }
  580. .unbind {
  581. cursor: pointer;
  582. }
  583. }
  584. }
  585. }
  586. </style>