index.vue 35 KB

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