index.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  1. <template>
  2. <div class="app-container">
  3. <div >
  4. <div style="background-color: #fff;padding: 20px;border-radius: 10px; padding-bottom: 0;">
  5. <p style="margin: 0; font-weight: 800;font-size: 16px;color: #343434;display: flex;align-items: center;margin-bottom: 20px;border-left: 6px solid #03BF8A;margin-left: -20px;">
  6. <!-- <img src="../../../assets/images/icon_htgl_btzs.png" alt="" style="width: 16px;height: 20px;"> -->
  7. <span style="margin-left: 10px;">搜索条件</span>
  8. </p>
  9. <div style="padding-bottom: 0;margin-bottom: 20px;">
  10. <el-form class="qucheu" :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="108px">
  11. <el-row>
  12. <el-col :span="24">
  13. <el-col :span="8">
  14. <el-form-item label="单位名称" prop="unitName">
  15. <el-input
  16. v-model="queryParams.unitName"
  17. placeholder="请输入单位名称"
  18. clearable
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="8">
  24. <el-form-item label="联系方式" prop="staffPhone">
  25. <el-input
  26. v-model="queryParams.staffPhone"
  27. placeholder="请输入人员联系方式"
  28. clearable
  29. @keyup.enter.native="handleQuery"
  30. />
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="5">
  34. <el-form-item class="butt" style="border: 0;">
  35. <el-button style="background-color: #03BF8A; border-color: #03BF8A;" type="primary" size="mini" @click="handleQuery">查询 </el-button>
  36. <el-button size="mini" @click="resetQuery">重置</el-button>
  37. </el-form-item>
  38. </el-col>
  39. </el-col>
  40. </el-row>
  41. </el-form>
  42. </div>
  43. </div>
  44. <div class="casr" >
  45. <el-row :gutter="10" class="mb8">
  46. <!-- <el-col :span="1.5">
  47. <div style="font-weight: bold;font-size: 14px;color: #343434; display: flex;align-items: center;">
  48. 当夜全选
  49. </div>
  50. </el-col> -->
  51. <!-- <el-col :span="1.5">
  52. <el-button
  53. type="success"
  54. plain
  55. size="mini"
  56. @click="handleAdd"
  57. v-hasPermi="['manage:staffManage:add']"
  58. >添加</el-button>
  59. </el-col> -->
  60. <!-- <el-col :span="1.5">
  61. <el-button
  62. type="success"
  63. plain
  64. size="mini"
  65. :disabled="single"
  66. @click="handleUpdate"
  67. v-hasPermi="['system:post:edit']"
  68. >修改</el-button>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button
  72. type="danger"
  73. plain
  74. size="mini"
  75. :disabled="multiple"
  76. @click="handleDelete"
  77. v-hasPermi="['system:post:remove']"
  78. >删除</el-button>
  79. </el-col> -->
  80. <el-col :span="1.5">
  81. <el-button
  82. type="warning"
  83. plain
  84. size="mini"
  85. @click="handleExport"
  86. v-hasPermi="['manage:staffManage:export']"
  87. >导出</el-button>
  88. </el-col>
  89. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  90. </el-row>
  91. <div class=" infinite-list" :style="dynamicStyle">
  92. <el-row :gutter="10" v-if="staffManageList.length !=0" style="width:100%;margin-left: 0;">
  93. <el-col :span="6" v-for="(item,index) in staffManageList" :key="index" >
  94. <!-- @click="isac(item)" -->
  95. <div v-if="isshoe" :class=" item.isnum ==true ? 'ingwe' :'' " style="position: relative; background-color: #fff;box-shadow: 0px 0px 10px 0px #CDCDCD;border-radius: 4px;margin-bottom: 10px;">
  96. <div style="display: flex; align-items: center;padding: 15px 20px; position: relative;padding-bottom: 0;">
  97. <div style="width: 22%;margin-top: -60px;">
  98. <!-- <image-preview :src="item.staffImage" :width="50" :height="50" style="border-radius:50%;margin-top: -10px;"/> -->
  99. <img src="../../../assets/images/icon_htgl_rylb_mrtx.png" alt="" style="width: 50px;height: 50px;border-radius: 50%;" >
  100. </div>
  101. <div class="haned" style="width: 88%; padding-right: 20px;">
  102. <p style="margin-bottom: 5px;">
  103. <span style="font-weight: bold;font-size: 16px;color: #161616;margin-left: 15px;margin-right: 10px;">{{item.personName ==null?'暂无数据' : item.personName}}</span>
  104. <!-- <img v-hasPermi="['manage:staffManage:edit']" src="../../../assets/images/icon_htgl_rylb_bj.png" alt="" style="cursor: pointer;" @click="handleUpdate(item)"> -->
  105. <!-- <img v-hasPermi="['manage:staffManage:remove']" src="../../../assets/images/icon_htgl_rylb_del.png" alt="" style="float: right;cursor: pointer;" @click="handleDelete(item)"> -->
  106. </p>
  107. <div style="display: flex; margin-left: 15px;font-size: 14px;color: #666666;margin-top: 5px;">
  108. <p style="text-align: left; width: 70px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" > 电话号码:</p>
  109. <p style="width: 62%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-left: 5px;font-size: 14px;color: #666666;">
  110. {{item.phonenumber ==null?'暂无数据' : item.phonenumber}}
  111. </p>
  112. </div>
  113. <div style="display: flex; margin-left: 15px;font-size: 14px;color: #666666;margin-top: 5px;">
  114. <p style="width: 70px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" >单位名称:</p>
  115. <el-tooltip class="item" effect="dark" :content="item.unitName ==null?'暂无数据' : item.unitName" placement="top-start">
  116. <p style="width: 62%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-left: 5px;font-size: 14px;color: #666666;">
  117. {{item.unitName ==null?'暂无数据' : item.unitName}}
  118. </p>
  119. </el-tooltip>
  120. </div>
  121. <div style=" display: flex; margin-left: 15px;font-size: 14px;color: #666666;margin-top: 5px;">
  122. <p style="width: 70px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">详细地址:</p>
  123. <el-tooltip class="item" effect="dark" :content="item.detailedAddress ==null?'暂无数据' : item.city + item.region +item.detailedAddress" placement="top-start">
  124. <p style="width: 62%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-left: 5px;font-size: 14px;color: #666666;">
  125. {{item.detailedAddress ==null?'暂无数据' : (item.city + item.region +item.detailedAddress)}}
  126. </p>
  127. </el-tooltip>
  128. </div>
  129. </div>
  130. </div>
  131. <!-- <div class="weit">
  132. <p>开发部</p>
  133. <p>白名单</p>
  134. </div> -->
  135. <!-- <img v-if="item.isnum == true" src="../../../assets/images/icon_htgl_kp_gx.png" alt="" style="width: 35px;height: 35px;position: absolute;bottom: 0;right: 0;"> -->
  136. <div class="bortt tongty" style="justify-content: space-between; margin-top: 0;">
  137. <p style="cursor: pointer;" @click="handleUpdate(item)"><span >查看</span></span> </p>
  138. <!-- <span @click="handleUpdatef(item)">查看</span> -->
  139. <p v-hasPermi="['basic:info:remove']" style="color:red;cursor: pointer;" @click="handleDelete(item)">删除 </p>
  140. </div>
  141. </div>
  142. </el-col>
  143. </el-row>
  144. <div style="margin-top: 20px;display: flex;justify-content: center;align-items: center;" v-if="staffManageList.length ==0">
  145. <img src="../../../assets/images/zwshjbig.png" alt="" style="">
  146. </div>
  147. </div>
  148. </div>
  149. <paginations
  150. v-show="total>0"
  151. :total="total"
  152. :page.sync="queryParams.pageNum"
  153. :limit.sync="queryParams.pageSize"
  154. @pagination="getList"
  155. />
  156. </div>
  157. <!-- 添加或修改岗位对话框 -->
  158. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  159. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  160. <el-row :gutter="20" class="ite">
  161. <el-col :span="16">
  162. <el-col :span="24">
  163. <el-form-item label="人员姓名" prop="staffName">
  164. <el-input v-model="form.staffName" placeholder="请输入人员姓名" />
  165. </el-form-item>
  166. </el-col>
  167. <el-col :span="24">
  168. <el-form-item label="人员联系方式" prop="staffPhone">
  169. <el-input v-model="form.staffPhone" placeholder="请输入人员联系方式" />
  170. </el-form-item>
  171. </el-col>
  172. <el-col :span="24">
  173. <el-form-item label="紧急联系人" prop="emergencyContact">
  174. <el-input v-model="form.emergencyContact" placeholder="请输入紧急联系人" />
  175. </el-form-item>
  176. </el-col>
  177. <el-col :span="24">
  178. <el-form-item label="紧急联系人手机" prop="emergencyContactPhone">
  179. <el-input v-model="form.emergencyContactPhone" placeholder="请输入紧急联系人手机" />
  180. </el-form-item>
  181. </el-col>
  182. </el-col>
  183. <el-col :span="8" class="sgwe unimg" style="border: 1px solid #F8F8F8;height: 235px;">
  184. <div style=" margin:10px 0; font-weight: bold;font-size: 14px;color: #333333;text-align: center;">人脸照片</div>
  185. <image-uploadr :limit="1" v-model="form.staffImage"/>
  186. <div style="font-weight: bold;font-size: 14px;color: #03BF8A;text-align: center;margin-top: 10px;" @click="openClick">点击拍照</div>
  187. <!-- onTake -->
  188. </el-col>
  189. <!-- <el-col :span="24"> -->
  190. <!-- </el-col> -->
  191. </el-col>
  192. </el-row>
  193. </el-form>
  194. <div slot="footer" class="dialog-footer">
  195. <el-button style="background-color:#03BF8A ; border-color: #03BF8A;" type="primary" @click="submitForm">确 定</el-button>
  196. <el-button style="background-color:#DDEBE7 ; border-color: #DDEBE7; color: #475669;" @click="cancel">取 消</el-button>
  197. </div>
  198. </el-dialog>
  199. <photo ref="photo" v-model="form.staffImage" :title="'图片拍照上传'" />
  200. <!--开启摄像头的弹窗-->
  201. <!-- <div class="info2" @click="onTake">
  202. <el-image :src="form.url" style="padding-left: 200px;width: 600px; height:400px"></el-image>
  203. </div> -->
  204. <!--开启摄像头的拍照和-->
  205. <el-dialog title="拍照上传" :visible.sync="visible" @close="onCancel1" width="1065px" append-to-body>
  206. <div class="box">
  207. <video id="videoCamera" class="canvas" :width="videoWidth" :height="videoHeight" autoPlay></video>
  208. <canvas id="canvasCamera" class="canvas" :width="videoWidth" :height="videoHeight"></canvas>
  209. </div>
  210. <div slot="footer">
  211. <el-button @click="drawImage" icon="el-icon-camera" size="small">
  212. 拍照
  213. </el-button>
  214. <el-button v-if="os" @click="getCompetence" icon="el-icon-video-camera" size="small">
  215. 打开摄像头
  216. </el-button>
  217. <el-button v-else @click="stopNavigator" icon="el-icon-switch-button" size="small">
  218. 关闭摄像头
  219. </el-button>
  220. <el-button @click="resetCanvas" icon="el-icon-refresh" size="small">
  221. 重置
  222. </el-button>
  223. <el-button @click="onCancel" icon="el-icon-circle-close"
  224. v-hasPermi="['system:oss:upload']"
  225. type="primary" size="small">
  226. 完成
  227. </el-button>
  228. </div>
  229. </el-dialog>
  230. </div>
  231. </template>
  232. <script>
  233. const defaultSettings = require("@/settings.js");
  234. import { listStaffManage, getStaffManage, delStaffManage, addStaffManage, updateStaffManage,unploa } from "@/api/system/staffManage"
  235. export default {
  236. name: "ResidentInfo",
  237. dicts: ['affiliation_personnel', 'sys_yes_no', 'gender','zhuhu_type', 'relationship_householder','renzhen_sh'],
  238. data() {
  239. return {
  240. // 遮罩层
  241. // 遮罩层
  242. loading: true,
  243. // 选中数组
  244. ids: [],
  245. // 非单个禁用
  246. single: true,
  247. // 非多个禁用
  248. multiple: true,
  249. // 显示搜索条件
  250. showSearch: true,
  251. // 总条数
  252. total: 0,
  253. // 人员管理表格数据
  254. staffManageList: [],
  255. // 弹出层标题
  256. title: "",
  257. // 是否显示弹出层
  258. open: false,
  259. // 查询参数
  260. queryParams: {
  261. pageNum: 1,
  262. pageSize: 10,
  263. staffName: null,
  264. staffPhone: null,
  265. emergencyContact: null,
  266. emergencyContactPhone: null,
  267. staffImage: null,
  268. },
  269. // 表单参数
  270. form: {},
  271. // 表单校验
  272. rules: {
  273. staffName: [
  274. { required: true, message: "不能为空", trigger: "blur" }
  275. ],
  276. staffPhone: [
  277. { required: true, message: "不能为空", trigger: "blur" },
  278. {
  279. pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
  280. message: "请输入正确的手机号码",
  281. trigger: "blur"
  282. }
  283. ],
  284. },
  285. activeName:'first',
  286. videoState: false, // 视频播放状态
  287. poster:true,
  288. controls:true,
  289. videoData:{},
  290. player: null,
  291. isshoe:true,
  292. tableMaxHeight:'200',
  293. tenantListtw:[],
  294. houseInfoLisen:[],
  295. isxin:false,
  296. imgSrc: "",
  297. visible: false,//弹窗
  298. loading: false,//上传按钮加载
  299. open: false,//控制摄像头开关
  300. thisVideo: null,
  301. thisContext: null,
  302. thisCancas: null,
  303. videoWidth: 500,
  304. videoHeight: 400
  305. };
  306. },
  307. computed: {
  308. dynamicStyle() {
  309. return {
  310. overflow:'auto',
  311. height: this.tableMaxHeight+ 'px',
  312. paddingTop:'10px'
  313. }
  314. }
  315. },
  316. created() {
  317. // if(this.$route.query.id != undefined){
  318. // this.queryParams.houseId = this.$route.query.id - 0
  319. // }
  320. // this.usename = this.$store.state.user.name
  321. this.getList();
  322. window.onresize = () => {
  323. this.changeTableMaxHeight()
  324. }
  325. this.changeTableMaxHeight()
  326. },
  327. mounted() {
  328. window.onresize = () => {
  329. this.changeTableMaxHeight()
  330. }
  331. this.changeTableMaxHeight()
  332. },
  333. beforeDestroy() {
  334. if (this.player) {
  335. this.player.dispose()
  336. }
  337. },
  338. methods: {
  339. openClick() {
  340. this.$refs['photo'].dialogPhotoVisible = true
  341. },
  342. /** 查询岗位列表 */
  343. getList() {
  344. this.loading = true;
  345. listStaffManage(this.queryParams).then(response => {
  346. this.staffManageList = response.rows;
  347. this.staffManageList .filter(rou=>{
  348. rou.imges = []
  349. if(rou.idCardFront != null && rou.idCardFront != ''){
  350. rou.imges.push(rou.idCardFront)
  351. }
  352. if(rou.idCardBack != null && rou.idCardBack != ''){
  353. rou.imges.push(rou.idCardBack)
  354. }
  355. rou.isnum = false
  356. })
  357. this.total = response.total;
  358. this.loading = false;
  359. });
  360. },
  361. shiegw(val){
  362. console.log(val)
  363. var _IDRe18 = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
  364. // var _IDre15 = /^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/
  365. // 校验身份证:
  366. // return (_IDRe18.test(idNo) || _IDre15.test(idNo)) ? true : false;
  367. if(_IDRe18.test(this.form.residentIdCard) == true){
  368. let sge = this.getInfo( this.form.residentIdCard)
  369. this.form.yearsOld = sge.age
  370. this.form.residentGender = sge.sex + ''
  371. this.form.residentBirthday = sge.birth
  372. console.log(sge)
  373. }
  374. },
  375. uploadedSuccessfully(row){
  376. console.log('上传重构',row)
  377. if(row.length !=0){
  378. row.filter(ru=>{
  379. this.form.residentName = ru.realName
  380. this.form.residentIdCard = ru.idCard
  381. let sge = this.getInfo( this.form.residentIdCard)
  382. this.form.yearsOld = sge.age
  383. this.form.residentGender = sge.sex + ''
  384. // this.form.residentBirthday = sge.birth
  385. })
  386. }
  387. },
  388. // 取消按钮
  389. cancel() {
  390. this.open = false;
  391. this.reset();
  392. },
  393. // 表单重置
  394. reset() {
  395. this.form = {
  396. staffId: null,
  397. staffName: null,
  398. staffPhone: null,
  399. emergencyContact: null,
  400. emergencyContactPhone: null,
  401. staffImage: null,
  402. delFlag: null,
  403. createBy: null,
  404. createTime: null,
  405. updateBy: null,
  406. updateTime: null,
  407. remark: null
  408. }
  409. this.resetForm("form");
  410. },
  411. /** 搜索按钮操作 */
  412. handleQuery() {
  413. this.queryParams.pageNum = 1
  414. this.getList()
  415. },
  416. /** 重置按钮操作 */
  417. resetQuery() {
  418. this.resetForm("queryForm")
  419. this.handleQuery()
  420. },
  421. // 多选框选中数据
  422. handleSelectionChange(selection) {
  423. this.ids = selection.map(item => item.staffId)
  424. this.single = selection.length!==1
  425. this.multiple = !selection.length
  426. },
  427. /** 新增按钮操作 */
  428. handleAdd() {
  429. this.reset()
  430. this.open = true
  431. this.title = "添加人员管理"
  432. },
  433. /** 修改按钮操作 */
  434. handleUpdate(row) {
  435. this.reset()
  436. const staffId = row.staffId || this.ids
  437. getStaffManage(staffId).then(response => {
  438. this.form = response.data
  439. this.open = true
  440. this.title = "修改人员管理"
  441. })
  442. },
  443. /** 提交按钮 */
  444. submitForm() {
  445. this.$refs["form"].validate(valid => {
  446. if (valid) {
  447. if (this.form.staffId != null) {
  448. updateStaffManage(this.form).then(response => {
  449. this.$modal.msgSuccess("修改成功")
  450. this.open = false
  451. this.getList()
  452. })
  453. } else {
  454. addStaffManage(this.form).then(response => {
  455. this.$modal.msgSuccess("新增成功")
  456. this.open = false
  457. this.getList()
  458. })
  459. }
  460. }
  461. })
  462. },
  463. /** 删除按钮操作 */
  464. handleDelete(row) {
  465. const staffIds = row.staffId || this.ids
  466. this.$modal.confirm('是否确认删除人员管理编号为"' + staffIds + '"的数据项?').then(function() {
  467. return delStaffManage(staffIds)
  468. }).then(() => {
  469. this.getList()
  470. this.$modal.msgSuccess("删除成功")
  471. }).catch(() => {})
  472. },
  473. /** 导出按钮操作 */
  474. handleExport() {
  475. this.download('manage/staffManage/export', {
  476. ...this.queryParams
  477. }, `staffManage_${new Date().getTime()}.xlsx`)
  478. },
  479. handleClick(){
  480. },
  481. isac(val){
  482. console.log(5,val)
  483. val.isnum = !val.isnum
  484. this.isshoe = false
  485. this.isshoe = true
  486. },
  487. itneg(item){
  488. this.queryParams.houseId = item.houseId
  489. this.queryParams.detailedAddress = item.detailedAddress
  490. },
  491. itnegadd(item){
  492. this.form.houseId = item.houseId
  493. this.form.detailedAddress = item.detailedAddress
  494. },
  495. // 获取屏幕高度
  496. showFilterForm () {
  497. this.filterActive = !this.filterActive
  498. this.changeTableMaxHeight()
  499. },
  500. changeTableMaxHeight () {
  501. let height = document.body.offsetHeight // 网页可视区域高度
  502. // if (this.filterActive) {
  503. // this.tableMaxHeight = height - 320
  504. // } else {
  505. this.tableMaxHeight = height - 150
  506. // }
  507. console.log(height)
  508. },
  509. onTake() {
  510. this.visible = true;
  511. this.getCompetence();
  512. },
  513. /*关闭弹窗,以及关闭摄像头功能*/
  514. onCancel1() {
  515. this.visible = false;
  516. this.stopNavigator(); // 关闭摄像头
  517. },
  518. // 调用摄像头权限
  519. getCompetence() {
  520. //必须在model中render后才可获取到dom节点,直接获取无法获取到model中的dom节点
  521. this.$nextTick(() => {
  522. const _this = this;
  523. this.os = false; //切换成关闭摄像头
  524. // 获取画布节点
  525. this.thisCancas = document.getElementById("canvasCamera");
  526. // 为画布指定绘画为2d类型
  527. this.thisContext = this.thisCancas.getContext("2d");
  528. //获取video节点
  529. this.thisVideo = document.getElementById("videoCamera");
  530. // 旧版本浏览器可能根本不支持mediaDevices,我们首先设置一个空对象
  531. if (navigator.mediaDevices === undefined) {
  532. navigator.menavigatordiaDevices = {};
  533. }
  534. // 一些浏览器实现了部分mediaDevices,我们不能只分配一个对象
  535. // 使用getUserMedia,因为它会覆盖现有的属性。
  536. // 这里,如果缺少getUserMedia属性,就添加它。
  537. if (navigator.mediaDevices.getUserMedia === undefined) {
  538. navigator.mediaDevices.getUserMedia = function(constraints) {
  539. // 首先获取现存的getUserMedia(如果存在)
  540. let getUserMedia =
  541. navigator.webkitGetUserMedia ||
  542. navigator.mozGetUserMedia ||
  543. navigator.getUserMedia;
  544. // 有些浏览器不支持,会返回错误信息
  545. // 保持接口一致
  546. if (!getUserMedia) {
  547. return Promise.reject(
  548. new Error("getUserMedia is not implemented in this browser")
  549. );
  550. }
  551. // 否则,使用Promise将调用包装到旧的navigator.getUserMedia
  552. return new Promise(function(resolve, reject) {
  553. getUserMedia.call(navigator, constraints, resolve, reject);
  554. });
  555. };
  556. }
  557. const constraints = {
  558. audio: false,
  559. video: {
  560. width: _this.videoWidth,
  561. height: _this.videoHeight,
  562. transform: "scaleX(-1)"
  563. }
  564. };
  565. navigator.mediaDevices
  566. .getUserMedia(constraints)
  567. .then(function(stream) {
  568. // 旧的浏览器可能没有srcObject
  569. if ("srcObject" in _this.thisVideo) {
  570. _this.thisVideo.srcObject = stream;
  571. } else {
  572. // 避免在新的浏览器中使用它,因为它正在被弃用。
  573. _this.thisVideo.src = window.URL.createObjectURL(stream);
  574. }
  575. _this.thisVideo.onloadedmetadata = function(e) {
  576. console.log(e)
  577. _this.thisVideo.play();
  578. };
  579. })
  580. .catch(err => {
  581. console.log(err)
  582. this.$notify({
  583. title: "警告",
  584. message: "没有开启摄像头权限或浏览器版本不兼容.",
  585. type: "warning"
  586. });
  587. });
  588. });
  589. },
  590. //调用摄像头 --- 进行绘制图片
  591. drawImage() {
  592. // 点击,canvas画图
  593. this.thisContext.drawImage(
  594. this.thisVideo,
  595. 0,
  596. 0,
  597. this.videoWidth,
  598. this.videoHeight
  599. );
  600. // 获取图片base64链接
  601. this.imgSrc = this.thisCancas.toDataURL("image/png");
  602. /*const imgSrc=this.imgSrc;*/
  603. },
  604. //清空画布
  605. clearCanvas(id) {
  606. let c = document.getElementById(id);
  607. let cxt = c.getContext("2d");
  608. cxt.clearRect(0, 0, c.width, c.height);
  609. },
  610. //重置画布
  611. resetCanvas() {
  612. // this.imgSrc = "";
  613. this.clearCanvas("canvasCamera");
  614. },
  615. //关闭摄像头
  616. stopNavigator() {
  617. if (this.thisVideo && this.thisVideo !== null) {
  618. this.thisVideo.srcObject.getTracks()[0].stop();
  619. this.os = true; //切换成打开摄像头
  620. }
  621. },
  622. /*调用摄像头拍照结束*/
  623. /*完成拍照并对其照片进行上传*/
  624. onCancel() {
  625. this.visible = false;
  626. /* this.resetCanvas();*/
  627. // console.log(this.imgSrc);
  628. const file = this.imgSrc; // 把整个base64给file
  629. const time = (new Date()).valueOf();//生成时间戳
  630. const name = time + ".png"; // 定义文件名字(例如:abc.png , cover.png)
  631. const conversions = this.base64ImgtoFile(file, name); // 调用base64转图片方法
  632. const data = new FormData();
  633. data.append('file', conversions);
  634. // this.imgFile = this.dataURLtoFile(this.imgSrc, new Date() + ".png");
  635. // console.log(this.imgFile);
  636. // this.stopNavigator();
  637. // // let par = {
  638. // // photo: this.imgFile,
  639. // // };
  640. // let data = new FormData();
  641. // data.append("file", this.imgFile); //1是图片,2是视频
  642. // // data.append("code", this.addForm.code);
  643. // // checkbeforepersonalphoto上传图片的接口
  644. unploa(data).then(res => {
  645. console.log(res)
  646. if (res.code == "200") {
  647. this.$message({
  648. message: "上传成功",
  649. type: "success"
  650. });
  651. this.form.url = res.data.url;
  652. this.form.osid = res.data.ossId;
  653. }
  654. });
  655. },
  656. base64ImgtoFile(dataurl, filename = 'file') {
  657. console.log(dataurl)
  658. let arr = dataurl.split(',')
  659. let mime = arr[0].match(/:(.*?);/)[1]
  660. let suffix = mime.split('/')[1]
  661. let bstr = atob(arr[1])
  662. let n = bstr.length
  663. console.log(bstr)
  664. let u8arr = new Uint8Array(n)
  665. while (n--) {
  666. u8arr[n] = bstr.charCodeAt(n)
  667. }
  668. console.log(u8arr)
  669. console.log(new File([u8arr], `${filename}.${suffix}`, {
  670. type: mime
  671. }))
  672. return new File([u8arr], `${filename}.${suffix}`, {
  673. type: mime
  674. })
  675. },
  676. dataURLtoFile(dataurl, filename) {
  677. let arr = dataurl.split(',');
  678. let mime = arr[0].match(/:(.*?);/)[1];
  679. let bstr = atob(arr[1]);
  680. let n = bstr.length;
  681. let u8arr = new Uint8Array(n);
  682. while (n--) {
  683. u8arr[n] = bstr.charCodeAt(n)
  684. }
  685. console.log(new File([u8arr], filename, {type: mime}))
  686. return new File([u8arr], filename, {type: mime})
  687. },
  688. }
  689. };
  690. </script>
  691. <style lang="scss">
  692. .ite{
  693. .el-form-item{
  694. margin-bottom: 30px;
  695. }
  696. }
  697. .ingsek{
  698. .el-carousel__container{
  699. height: 150px;
  700. }
  701. .el-carousel--horizontal{
  702. width: 100%;
  703. }
  704. }
  705. .shefnze{
  706. .el-upload--picture-card{
  707. width: 80px;
  708. height: 80px;
  709. line-height: 80px;
  710. }
  711. .el-upload-list--picture-card .el-upload-list__item{
  712. width: 80px;
  713. height: 80px;
  714. }
  715. .el-upload__tip{
  716. overflow: hidden;
  717. text-overflow: ellipsis;
  718. white-space: nowrap;
  719. }
  720. }
  721. .ngeshimg{
  722. .el-upload--picture-card{
  723. width: 36px;
  724. height: 36px;
  725. line-height: 36px;
  726. position: absolute;
  727. top:0;
  728. right: 0;
  729. }
  730. .component-upload-image{
  731. position: absolute;
  732. top:0;
  733. right: 0;
  734. }
  735. .el-upload--picture-card i{
  736. font-size: 20px;
  737. }
  738. .el-upload-list--picture-card .el-upload-list__item{
  739. width: 58px;
  740. height: 36px;
  741. position: absolute;
  742. top:0;
  743. right: -10px;
  744. }
  745. }
  746. .unimg{
  747. .el-upload--picture-card{
  748. width:140px;
  749. height: 160px;
  750. margin-left: 15px;
  751. // line-height: 102px;
  752. background-color:#f8f8f8;
  753. border: 0;
  754. }
  755. .el-upload-list--picture-card .el-upload-list__item{
  756. margin-left: 15px;
  757. }
  758. }
  759. .bnjle{
  760. margin-left: 20px;
  761. }
  762. .butt{
  763. .el-button--small{
  764. padding: 9px 23px !important;
  765. font-size: 14px;
  766. }
  767. }
  768. .casr{
  769. .el-tabs__item.is-active{
  770. color: #196CFF;
  771. }
  772. .el-tabs--card > .el-tabs__header .el-tabs__item{
  773. padding: 0 30px !important;
  774. }
  775. }
  776. .el-table .el-table__header-wrapper th{
  777. background-color:#F5F6F8;
  778. color:#343434;
  779. }
  780. .el-table{
  781. color:#343434;
  782. }
  783. </style>
  784. <style scoped lang="scss">
  785. .goe{
  786. p{
  787. margin: 0;
  788. font-weight: 800;
  789. font-size: 16px;
  790. color: #161616;
  791. margin-top: 10px;
  792. margin-bottom: 3px;
  793. padding: 0 10px;
  794. overflow: hidden;
  795. text-overflow: ellipsis;
  796. display:-webkit-box; //作为弹性伸缩盒子模型显示。
  797. -webkit-box-orient:vertical; //设置伸缩盒子的子元素排列方式--从上到下垂直排列
  798. -webkit-line-clamp:1; //显示的行
  799. }
  800. p:nth-child(2){
  801. }
  802. }
  803. .ingwe{
  804. border: 2px solid #196CFF;
  805. }
  806. .renyuangs{
  807. p{
  808. font-weight: 500;
  809. font-size: 14px;
  810. color: #161616;
  811. padding: 0;
  812. }
  813. div{
  814. font-weight: 500;
  815. font-size: 14px;
  816. color: #161616;
  817. padding: 0;
  818. display: flex;
  819. }
  820. }
  821. .tongty{
  822. display: flex;
  823. align-items: center;
  824. }
  825. .bortt{
  826. border-top: 1px solid #DADADA;
  827. margin-top: 15px;
  828. p{
  829. margin: 0;
  830. font-weight: bold;
  831. font-size: 14px;
  832. color: #5F8BF4;
  833. width:50%;
  834. padding: 10px;
  835. text-align: center;
  836. }
  837. }
  838. .wide{
  839. width:100% !important;
  840. }
  841. .haned{
  842. flex:1;
  843. padding-bottom: 15px;
  844. p{
  845. margin: 0;
  846. }
  847. }
  848. .weit{
  849. display: flex;
  850. padding-left: 85px;
  851. padding-bottom: 10px;
  852. margin-top: 10px;
  853. p{
  854. margin: 0;
  855. font-weight: 500;
  856. font-size: 14px;
  857. color: #009FE8;
  858. border-radius: 10px;
  859. border: 1px solid #009FE8;
  860. padding: 2px 5px;
  861. margin-right: 10px;
  862. }
  863. p:nth-child(2){
  864. color: #FFAB2B;
  865. border: 1px solid #FFAB2B;
  866. }
  867. }
  868. </style>