移动端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

employer.vue 14 KiB

1年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <div class="app-container">
  3. <van-nav-bar left-arrow fixed placeholder @click-left="$router.push({path:'/contracted/index'})" >
  4. <template #title>
  5. <div class="tb_main">
  6. {{ $route.query.deptName }}
  7. </div>
  8. </template>
  9. </van-nav-bar>
  10. <div class="tap_block">
  11. <p @click="$router.push({path:'/contracted/village/contractor', query: { deptId: $route.query.deptId, deptName: $route.query.deptName }})">承包方</p>
  12. <p class="active">发包方</p>
  13. <p @click="$router.push({path:'/contracted/village/massif', query: { deptId: $route.query.deptId, deptName: $route.query.deptName }})">地块</p>
  14. <p @click="$router.push({path:'/contracted/village/map', query: { deptId: $route.query.deptId, deptName: $route.query.deptName }})">地图</p>
  15. </div>
  16. <div class="list_main">
  17. <van-form ref="formData">
  18. <van-field v-model="form.fbfbm" label="代码:" placeholder="请输入代码" required :rules="[{ required: true }]" :border="false" input-align="right" label-width="auto" :disabled="isDisabled" maxlength="14">
  19. <template #button v-if="!isDisabled">
  20. <van-button size="mini" type="primary" native-type="button" @click="generateCode">生成代码</van-button>
  21. </template>
  22. </van-field>
  23. <van-field v-model="form.fbfmc" label="名称:" placeholder="请输入名称" required :rules="[{ required: true }]" :border="false" input-align="right" label-width="auto" maxlength="50" />
  24. <van-field v-model="form.fbffzrxm" label="负责人姓名:" placeholder="请输入负责人姓名" required :rules="[{ required: true }]" :border="false" input-align="right" label-width="auto" maxlength="50" />
  25. <van-field v-model="credentialTypeText" label="证件类型:"
  26. placeholder="请选择证件类型"
  27. required
  28. :rules="[{ required: true }]"
  29. :border="false"
  30. input-align="right"
  31. right-icon="arrow-down"
  32. label-width="auto"
  33. readonly
  34. clickable
  35. @click="showCredentialType = true"
  36. />
  37. <van-popup v-model="showCredentialType" position="bottom">
  38. <van-picker
  39. show-toolbar
  40. :columns="credentialTypeOptions"
  41. value-key="dictLabel"
  42. @confirm="onConfirmTypeOptions"
  43. @cancel="showCredentialType = false"
  44. />
  45. </van-popup>
  46. <van-field v-model="form.fzrzjhm" label="证件号码:" placeholder="请输入证件号码" required :rules="[{ required: true }]" :border="false" input-align="right" label-width="auto" maxlength="30" />
  47. <van-field v-model="form.lxdh" label="联系电话:" placeholder="请输入联系电话" required :rules="[{ required: true }]" :border="false" input-align="right" label-width="auto" maxlength="15" />
  48. <van-field v-model="form.fbfdz" label="地址:" placeholder="请输入地址" required :rules="[{ required: true }]" :border="false" input-align="right" label-width="auto" maxlength="100" />
  49. <van-field v-model="form.yzbm" label="邮政编码:" placeholder="请输入邮政编码" required :rules="[{ required: true }]" :border="false" input-align="right" label-width="auto" maxlength="6" />
  50. <van-field v-model="form.fbfdcjs" label="调查记事:" placeholder="请输入调查记事" type="textarea" rows="3" required :rules="[{ required: true }]" :border="false" input-align="right" label-width="auto" maxlength="200" />
  51. <van-field label="签字图片:" readonly :border="false" label-width="auto" />
  52. <img :src="'/api'+form.fbfdcqz" width="100%" alt="" />
  53. </van-form>
  54. <div class="btn_main" v-if="taskStatus === '2'">
  55. <p class="btn" @click="submitForm">保存</p>
  56. <p class="btn1" @click="handleSign">签字</p>
  57. </div>
  58. </div>
  59. <van-popup v-model="showSignPopup" closeable position="right" :style="{ height: '100%' }" >
  60. <van-cell-group style="width: 100%;height:100%;overflow: hidden;padding-top: 10px;padding-bottom: 10px;">
  61. <div class="signature-box" @mousedown="canvasTTdown" @touchstart="canvasTTdown">
  62. <vue-esign
  63. ref="esign"
  64. class="mySign"
  65. :width="500"
  66. :height="height"
  67. :isCrop="signature.isCrop"
  68. :lineWidth="signature.lineWidth"
  69. :lineColor="signature.lineColor"
  70. :bgColor.sync="signature.bgColor"
  71. />
  72. </div>
  73. <img src="../../../../assets/images/sunVillage_info/signature_icon_10.png" id="canvasTT" style="position:absolute;top: 50%;left: 50%;transform: translate(-50%,-50%)" alt="">
  74. <div class="signature-footer">
  75. <van-button @click="handleReset" class="clearBtn" type="info" plain size="small">清空画板</van-button>
  76. <van-button @click="handleGenerate" type="info" size="small">保存签字</van-button>
  77. </div>
  78. </van-cell-group>
  79. </van-popup>
  80. </div>
  81. </template>
  82. <script>
  83. import Cookies from "js-cookie";
  84. import { listFbf, addFbf, updateFbf, manualSignature, generateEmployerCode } from "@/api/contracted/fbf";
  85. import vueEsign from "vue-esign";
  86. import $ from "jquery";
  87. export default {
  88. name: "contractedVillageContractor",
  89. components: {
  90. vueEsign
  91. },
  92. data() {
  93. return {
  94. form: {}, // 发包方信息表单
  95. isDisabled: false, // 是否禁用
  96. credentialTypeOptions: [], // 证件类型字典
  97. credentialTypeText: null, // 证件类型标签名
  98. showCredentialType: false, // 控制证件类型字典弹出层的显示和隐藏
  99. taskStatus: null, // 调查任务的完成状态:1表示已完成,2表示未完成
  100. // 控制签字面板的显示和隐藏
  101. showSignPopup: false,
  102. height: null,
  103. //电子签名
  104. signature: {
  105. lineWidth: 6, // 画笔的线条粗细
  106. lineColor: "#000000", // 画笔的颜色
  107. bgColor: "", // 画布的背景颜色
  108. resultImg: "", // 最终画布生成的base64图片
  109. isCrop: false, // 是否裁剪,在画布设定尺寸基础上裁掉四周空白部分
  110. },
  111. };
  112. },
  113. created() {
  114. this.taskStatus = Cookies.get('taskStatus');
  115. this.height = window.screen.height * 1.28 - 20;
  116. this.getDicts("cert_type").then(response => {
  117. this.credentialTypeOptions = response.data;
  118. });
  119. this.getDetail();
  120. },
  121. methods: {
  122. getDetail() {
  123. listFbf({deptId: this.$route.query.deptId}).then(response => {
  124. if (response.rows.length > 0) {
  125. this.form = response.rows[0];
  126. this.isDisabled = true;
  127. this.$nextTick(() => {
  128. this.credentialTypeText = this.selectDictLabel(this.credentialTypeOptions, this.form.fzrzjlx);
  129. });
  130. } else {
  131. this.resetForm();
  132. this.isDisabled = false;
  133. }
  134. });
  135. },
  136. generateCode() {
  137. generateEmployerCode({deptId: this.$route.query.deptId}).then(response => {
  138. this.$set(this.form, 'fbfbm', response.data);
  139. });
  140. },
  141. onConfirmTypeOptions(value){
  142. this.form.fzrzjlx = value.dictValue;
  143. this.credentialTypeText = value.dictLabel;
  144. this.showCredentialType = false;
  145. },
  146. submitForm() {
  147. this.$refs.formData.validate().then(() => {
  148. if (this.form.id) {
  149. updateFbf(this.form).then(response => {
  150. if (response.code == 200) {
  151. this.$toast({
  152. icon: 'success',
  153. message: '保存成功',
  154. duration:"1000",
  155. });
  156. }
  157. });
  158. } else {
  159. this.form.deptId = this.$route.query.deptId;
  160. addFbf(this.form).then(response => {
  161. if (response.code == 200) {
  162. this.$toast({
  163. icon: 'success',
  164. message: '保存成功',
  165. duration:"1000",
  166. onClose: () => {
  167. this.getDetail();
  168. }
  169. });
  170. }
  171. });
  172. }
  173. }).catch(() => {
  174. this.$notify({ type: 'danger', message: '请填写完整的表单项' });
  175. });
  176. },
  177. resetForm() {
  178. this.form = {
  179. deptId: null,
  180. fbfbm: null,
  181. fbfmc: null,
  182. fbffzrxm: null,
  183. fzrzjlx: '1',
  184. fzrzjhm: null,
  185. lxdh: null,
  186. fbfdz: null,
  187. yzbm: null,
  188. fbfdcjs: null,
  189. fbfdcqz: null
  190. };
  191. this.credentialTypeText = '居民身份证';
  192. },
  193. handleSign() {
  194. this.showSignPopup = true;
  195. this.handleReset();
  196. },
  197. canvasTTdown() {
  198. $('#canvasTT').css('display', 'none');
  199. },
  200. // 清空画板
  201. handleReset() {
  202. if (this.$refs.esign) {
  203. this.$refs.esign.reset();
  204. }
  205. $('#canvasTT').css('display', 'block')
  206. },
  207. // 生成签字图片
  208. handleGenerate() {
  209. this.$refs.esign
  210. .generate() // 使用生成器调用把签字的图片转换成为base64图片格式
  211. .then((res) => {
  212. this.signature.resultImg = res;
  213. let wj = this.dataURLtoBlob(res);
  214. let param = new FormData(); // 创建form对象
  215. param.append('file', wj); // 通过append向form对象添加数据
  216. param.append('deptId', this.$route.query.deptId);
  217. manualSignature(param).then(response => {
  218. if (response.code === 200) {
  219. this.$toast({
  220. icon: 'success', // 找到自己需要的图标
  221. message: '签字成功',
  222. duration: "1000",
  223. onClose: () => {
  224. this.showSignPopup = false;
  225. this.form.fbfdcqz = response.data;
  226. }
  227. });
  228. }
  229. });
  230. })
  231. .catch((err) => {
  232. // 画布没有签字时会执行这里提示一下
  233. this.$toast.fail('请签名后再保存签字');
  234. });
  235. },
  236. dataURLtoBlob(dataurl, filename = 'file') {
  237. let arr = dataurl.split(',')
  238. let mime = arr[0].match(/:(.*?);/)[1]
  239. let suffix = mime.split('/')[1]
  240. let bstr = atob(arr[1])
  241. let n = bstr.length
  242. let u8arr = new Uint8Array(n)
  243. while (n--) {
  244. u8arr[n] = bstr.charCodeAt(n)
  245. }
  246. return new File([u8arr], `${filename}.${suffix}`, {
  247. type: mime
  248. })
  249. },
  250. },
  251. };
  252. </script>
  253. <style scoped lang="scss">
  254. .app-container{
  255. background: #fff url("../../../../../static/images/contracted/contracted_index_bg.png") no-repeat center;
  256. background-size: 100% 100%;
  257. height: 100vh;
  258. padding: 0 4vw;
  259. overflow: hidden;
  260. }
  261. /deep/ .van-nav-bar{
  262. background: transparent;
  263. }
  264. /deep/ .van-nav-bar .van-icon{
  265. color: #000000;
  266. }
  267. /deep/ .van-hairline--bottom::after{
  268. border: none;
  269. }
  270. /deep/ .van-search__content{
  271. background: rgba(255,255,255,.5);
  272. }
  273. /deep/ .van-search{
  274. padding: 0;
  275. flex: 1;
  276. }
  277. /deep/ .van-ellipsis{
  278. overflow: initial;
  279. }
  280. /deep/ .van-field--disabled .van-field__label {
  281. color: #646566;
  282. }
  283. .tb_main{
  284. position: relative;
  285. p{
  286. position: absolute;
  287. display: inline-block;
  288. margin-left: 10PX;
  289. }
  290. }
  291. .tb{
  292. font-size: 12px;
  293. color: #ff8900;
  294. background: #daf6e7;
  295. border: 1px solid #d7be6e;
  296. padding: 2PX 8PX;
  297. border-radius: 50PX;
  298. margin-right: 5PX;
  299. }
  300. .tap_block{
  301. width: 100%;
  302. display: flex;
  303. justify-content: space-between;
  304. background: #ebfaf2;
  305. padding: 2PX 4PX;
  306. border-radius: 10PX;
  307. margin-top: 1vh;
  308. .active{
  309. background-image: linear-gradient(to right,#c6fe8b,#48e5a2);
  310. box-shadow: 0 0 10PX #cccccc;
  311. color: #333333;
  312. }
  313. p{
  314. width: 25%;
  315. text-align: center;
  316. padding: 5PX 0;
  317. border-radius: 10PX;
  318. color: #666666;
  319. }
  320. }
  321. .search_main{
  322. display: flex;
  323. margin-top: 2vh;
  324. .search_btn{
  325. background: rgba(255,255,255,.5);
  326. width: 25%;
  327. border-radius: 50PX;
  328. margin-left: 10PX;
  329. padding: 2PX;
  330. .active{
  331. background-image: linear-gradient(to right,#c6fe8b,#48e5a2);
  332. color: #333333;
  333. border-radius: 50PX;
  334. display: flex;
  335. align-items: center;
  336. justify-content: center;
  337. height: 100%;
  338. }
  339. }
  340. }
  341. .second_tap{
  342. display: flex;
  343. align-items: center;
  344. margin-top: 1vh;
  345. p{
  346. background: #dbf1ea;
  347. border: 1px solid #cdcdcd;
  348. color: #5f5f5f;
  349. padding: 5PX 15PX;
  350. margin-right: 3vw;
  351. border-radius: 50PX;
  352. }
  353. .active{
  354. background: #99eecb;
  355. border-color: #48e5a2;
  356. color: #333333;
  357. }
  358. }
  359. .list_main{
  360. margin-top: 2vh;
  361. overflow-y: scroll;
  362. text-align: center;
  363. background: #ffffff;
  364. border-top-left-radius: 10PX;
  365. border-top-right-radius: 10PX;
  366. height: 88vh;
  367. .btn_main{
  368. .btn1{
  369. background-image: linear-gradient(to right,#ffd88e,#fc8a0e);
  370. box-shadow: 0 0 10PX #cccccc;
  371. padding: 10PX 0PX;
  372. border-radius: 50PX;
  373. display: inline-block;
  374. width: 30%;
  375. margin-top: 2vh;
  376. margin-left: 2vw;
  377. }
  378. .btn{
  379. background-image: linear-gradient(to right,#c6fe8b,#48e5a2);
  380. box-shadow: 0 0 10PX #cccccc;
  381. padding: 10PX 0PX;
  382. border-radius: 50PX;
  383. display: inline-block;
  384. width: 30%;
  385. margin-top: 2vh;
  386. }
  387. }
  388. }
  389. .mapBox{
  390. width: 94%;
  391. height: 50vw;
  392. background-image: linear-gradient(to right,#c6fe8b,#48e5a2);
  393. border-radius: 10PX;
  394. margin: 2vh auto;
  395. }
  396. .signature-box {
  397. border: 1px dashed #666;
  398. margin: 2px 20px;
  399. height: 100%;
  400. /*canvas{*/
  401. /* height: 100%!important;*/
  402. /*}*/
  403. }
  404. .signature-footer {
  405. transform: rotate(90deg);
  406. width: auto;
  407. position: absolute;
  408. top: 50%;
  409. left: 0PX;
  410. .clearBtn {
  411. margin-left: 15px;
  412. }
  413. }
  414. </style>