application.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. <template>
  2. <view class="uv-page" style="background-color: #fff;width: 94%;margin: 0 auto;">
  3. <view class="uv-demo-block">
  4. <view class="uv-demo-block__content">
  5. <!-- 注意,如果需要兼容微信小程序,最好通过setRules方法设置rules规则 -->
  6. <uv-form labelPosition="left" labelWidth="formdata100" :model="formdata" ref="form1" :rules="rules">
  7. <uv-form-item label="使用人姓名" required="required" prop="username" borderBottom labelWidth="100" ref="item1">
  8. <uv-input v-model="formdata.username" border="none" placeholder="请输入使用人姓名"></uv-input>
  9. </uv-form-item>
  10. <uv-form-item label="手机号" required="required" prop="mobile" borderBottom labelWidth="100" ref="item1">
  11. <uv-input v-model="formdata.mobile" border="none" placeholder="请输入联系电话"></uv-input>
  12. </uv-form-item>
  13. <uv-form-item label="借单类型" required="required" prop="purpose" borderBottom labelWidth="100" ref="item2">
  14. <uv-radio-group v-model="formdata.purpose">
  15. <uv-radio :customStyle="{marginRight: '16px'}" label="科研类" :name="0">
  16. </uv-radio>
  17. <uv-radio :customStyle="{marginRight: '16px'}" label="教学类" :name="1">
  18. </uv-radio>
  19. </uv-radio-group>
  20. </uv-form-item>
  21. <uv-form-item v-if="formdata.purpose == 0" label="项目编号" prop="project_number" borderBottom labelWidth="100" ref="item1">
  22. <uv-input v-model="formdata.project_number" border="none" placeholder="请输入项目编号"></uv-input>
  23. </uv-form-item>
  24. <uv-form-item label="预计领取时间" required="required" borderBottom prop="borrow_time" labelWidth="100" @click="showDateSelectBorrow" ref="formdata">
  25. <uv-input v-model="formdata.borrow_time" disabled disabledColor="#ffffff" border="none"></uv-input>
  26. <uv-datetime-picker :minDate="new Date()" ref="datetimePicker1" mode="datetime" @confirm="showDateconfirmBorrrow"></uv-datetime-picker>
  27. <template v-slot:right>
  28. <uv-icon name="arrow-right"></uv-icon>
  29. </template><strong></strong>
  30. </uv-form-item>
  31. <uv-form-item label="预计归还时间" required="required" borderBottom prop="expected_end_time" labelWidth="100" @click="showDateSelect" ref="formdata">
  32. <uv-input v-model="formdata.expected_end_time" disabled disabledColor="#ffffff" border="none"></uv-input>
  33. <uv-datetime-picker :minDate="new Date()" ref="datetimePicker" mode="datetime" @confirm="showDateconfirm"></uv-datetime-picker>
  34. <template v-slot:right>
  35. <uv-icon name="arrow-right"></uv-icon>
  36. </template><strong></strong>
  37. </uv-form-item>
  38. <view class="">
  39. <view class="uanze_title">
  40. <view class="xuanze_title">
  41. 选择仪器
  42. </view>
  43. <button type="primary" size="mini" @click="addasset" class="add_anniu">新增仪器类型</button>
  44. </view>
  45. <uv-form-item v-for="(item, idx) in formdata.asset" :key="idx">
  46. <view class="form-item">
  47. <!-- <cus-selects :closeSelect.sync='close' @change='change' v-model="item.model" :data="candidates" :valueType="alias" :filterable='true' :searchType='1'></cus-selects> -->
  48. <superwei-combox :candidates="candidates" :isJSON="true" keyName="value" placeholder="请选择或输入"
  49. v-model="item.model" @input="input_json" @select="select_json">
  50. </superwei-combox>
  51. <!-- <uv-form-item label="预计归还时间" required="required" borderBottom prop="expected_end_time" labelWidth="100" @click="showDateSelect" ref="formdata">
  52. <uv-input v-model="formdata.expected_end_time" disabled disabledColor="#ffffff" border="none"></uv-input>
  53. <uv-datetime-picker :minDate="new Date()" ref="datetimePicker" mode="datetime" @confirm="showDateconfirm"></uv-datetime-picker>
  54. <template v-slot:right>
  55. <uv-icon name="arrow-right"></uv-icon>
  56. </template><strong></strong>
  57. </uv-form-item> -->
  58. <!-- <uni-combox label="所在城市" :candidates="candidates" placeholder="请选择所在城市" v-model="item.model"></uni-combox> -->
  59. <!-- <superwei-combox :candidates="candidates" :isJSON="true" keyName="model" placeholder="请选择或输入"
  60. v-model="item.model" @input="input_json" @select="select_json">
  61. </superwei-combox> -->
  62. <!-- <uni-combox :candidates="candidates" placeholder="请选择仪器" v-model="item.model"></uni-combox> -->
  63. <!-- <picker @change="bindPickerChange" :value="index" :range="item.origins">
  64. <view class="uni-input">{{origins[index]}}</view>
  65. </picker> -->
  66. <!-- <uni-section title="本地数据" type="line">
  67. <view class="uni-px-5 uni-pb-5">
  68. <uni-data-picker
  69. placeholder="请选择班级"
  70. popup-title="请选择"
  71. :localdata="candidates"
  72. v-model="item.model"
  73. @change="onchange"
  74. @nodeclick="onnodeclick"
  75. @popupopened="onpopupopened"
  76. @popupclosed="onpopupclosed"
  77. @inputclick="inputclick"
  78. ></uni-data-picker>
  79. </view>
  80. </uni-section> -->
  81. <uv-input v-model="item.num" placeholder="数量"></uv-input>
  82. <button class="button" size="mini" type="default" @click="onDelArrayItem(idx)">删除</button>
  83. </view>
  84. </uv-form-item>
  85. <uv-picker ref="picker2" :columns="columns" @confirm="confirm2"></uv-picker>
  86. </view>
  87. <uv-form-item label="借取用途" required="required" prop="borrow_reason" borderBottom labelWidth="80" ref="item3">
  88. <uv-textarea placeholder="请填写借取用途" v-model="formdata.borrow_reason" count></uv-textarea>
  89. </uv-form-item>
  90. <view v-if="is_w">
  91. <view class="uanze_title">
  92. <view class="xuanze_title">
  93. 选择无人机配件
  94. </view>
  95. </view>
  96. <uv-form-item label="电池数量" required="required" prop="accessories.w_battery" borderBottom labelWidth="100" ref="item1">
  97. <uv-input v-model="formdata.accessories.w_battery" border="none" placeholder="请输入无人机电池数量"></uv-input>
  98. </uv-form-item>
  99. <uv-form-item label="遥控器数量" required="required" prop="accessories.w_remote_control" borderBottom labelWidth="100" ref="item1">
  100. <uv-input v-model="formdata.accessories.w_remote_control" border="none" placeholder="请输入无人机电遥控器数量"></uv-input>
  101. </uv-form-item>
  102. <uv-form-item label="遥控器电池数量" required="required" prop="accessories.w_remote_control_battery" borderBottom labelWidth="100" ref="item1">
  103. <uv-input v-model="formdata.accessories.w_remote_control_battery" border="none" placeholder="请输入无人机电遥控器电池数量"></uv-input>
  104. </uv-form-item>
  105. <uv-form-item label="充电管家" required="required" prop="accessories.w_charge_housekeeper" borderBottom labelWidth="100" ref="item1">
  106. <uv-input v-model="formdata.accessories.w_charge_housekeeper" border="none" placeholder="请输入无人机电充电管家数量"></uv-input>
  107. </uv-form-item>
  108. <uv-form-item label="螺旋桨" required="required" prop="accessories.w_propeller" borderBottom labelWidth="100" ref="item1">
  109. <uv-input v-model="formdata.accessories.w_propeller" border="none" placeholder="请输入无人机电螺旋桨数量"></uv-input>
  110. </uv-form-item>
  111. <uv-form-item label="SD卡" required="required" prop="accessories.w_sd" borderBottom labelWidth="100" ref="item1">
  112. <uv-input v-model="formdata.accessories.w_sd" border="none" placeholder="请输入无人机电SD卡数量"></uv-input>
  113. </uv-form-item>
  114. </view>
  115. <view v-if="is_q">
  116. <view class="uanze_title">
  117. <view class="xuanze_title">
  118. 选择全站仪配件
  119. </view>
  120. </view>
  121. <view>
  122. <uv-form-item label="主机电池" required="required" prop="accessories.q_battery" borderBottom labelWidth="100" ref="item1">
  123. <uv-input v-model="formdata.accessories.q_battery" border="none" placeholder="请输入全站仪电池数量"></uv-input>
  124. </uv-form-item>
  125. <uv-form-item label="主机充电器" required="required" prop="accessories.q_charge_housekeeper" borderBottom labelWidth="100" ref="item1">
  126. <uv-input v-model="formdata.accessories.q_charge_housekeeper" border="none" placeholder="请输入全站仪主机充电器数量"></uv-input>
  127. </uv-form-item>
  128. <uv-form-item label="三脚架" required="required" prop="accessories.q_tripod" borderBottom labelWidth="100" ref="item1">
  129. <uv-input v-model="formdata.accessories.q_tripod" border="none" placeholder="请输入三脚架数量"></uv-input>
  130. </uv-form-item>
  131. <uv-form-item label="棱镜" required="required" prop="accessories.q_prism" borderBottom labelWidth="100" ref="item1">
  132. <uv-input v-model="formdata.accessories.q_prism" border="none" placeholder="请输入棱镜数量"></uv-input>
  133. </uv-form-item>
  134. <uv-form-item label="对中杆" required="required" prop="accessories.q_center_bar" borderBottom labelWidth="100" ref="item1">
  135. <uv-input v-model="formdata.accessories.q_center_bar" border="none" placeholder="请输入对中杆数量"></uv-input>
  136. </uv-form-item>
  137. <uv-form-item label="数据线" required="required" prop="accessories.q_data_line" borderBottom labelWidth="100" ref="item1">
  138. <uv-input v-model="formdata.accessories.q_data_line" border="none" placeholder="请输入全站仪数据线数量"></uv-input>
  139. </uv-form-item>
  140. </view>
  141. </view>
  142. <view v-if="is_s">
  143. <view class="uanze_title">
  144. <view class="xuanze_title">
  145. 选择水准仪配件
  146. </view>
  147. </view>
  148. <uv-form-item label="主机电池" required="required" prop="accessories.s_battery" borderBottom labelWidth="100" ref="item1">
  149. <uv-input v-model="formdata.accessories.s_battery" border="none" placeholder="请输入主机电池数量"></uv-input>
  150. </uv-form-item>
  151. <uv-form-item label="充电器" required="required" prop="accessories.s_charge_housekeeper" borderBottom labelWidth="100" ref="item1">
  152. <uv-input v-model="formdata.accessories.s_charge_housekeeper" border="none" placeholder="请输入充电器数量"></uv-input>
  153. </uv-form-item>
  154. <uv-form-item label="电源线" required="required" prop="accessories.s_data_line" borderBottom labelWidth="100" ref="item1">
  155. <uv-input v-model="formdata.accessories.s_data_line" border="none" placeholder="请输入电源线数量"></uv-input>
  156. </uv-form-item>
  157. <uv-form-item label="调节扳手" required="required" prop="accessories.s_adjustment_wrench" borderBottom labelWidth="100" ref="item1">
  158. <uv-input v-model="formdata.accessories.s_adjustment_wrench" border="none" placeholder="请输入调节扳手数量"></uv-input>
  159. </uv-form-item>
  160. <uv-form-item label="防雨布" required="required" prop="accessories.s_rain_proof_cloth" borderBottom labelWidth="100" ref="item1">
  161. <uv-input v-model="formdata.accessories.s_rain_proof_cloth" border="none" placeholder="请输入防雨布数量"></uv-input>
  162. </uv-form-item>
  163. <uv-form-item label="三脚架" required="required" prop="accessories.s_tripod" borderBottom labelWidth="100" ref="item1">
  164. <uv-input v-model="formdata.accessories.s_tripod" border="none" placeholder="请输入三脚架数量"></uv-input>
  165. </uv-form-item>
  166. <uv-form-item label="水准尺" required="required" prop="accessories.s_level_gauge" borderBottom labelWidth="100" ref="item1">
  167. <uv-input v-model="formdata.accessories.s_level_gauge" border="none" placeholder="请输入水准尺数量"></uv-input>
  168. </uv-form-item>
  169. <uv-form-item label="尺垫" required="required" prop="accessories.s_ruler_pad" borderBottom labelWidth="100" ref="item1">
  170. <uv-input v-model="formdata.accessories.s_ruler_pad" border="none" placeholder="请输入尺垫数量"></uv-input>
  171. </uv-form-item>
  172. </view>
  173. <view v-if="is_r">
  174. <view class="uanze_title">
  175. <view class="xuanze_title">
  176. 选择RTK配件
  177. </view>
  178. </view>
  179. <uv-form-item label="主电" required="required" prop="accessories.r_battery" borderBottom labelWidth="100" ref="item1">
  180. <uv-input v-model="formdata.accessories.r_battery" border="none" placeholder="请输入主机电池数量"></uv-input>
  181. </uv-form-item>
  182. <uv-form-item label="主电充电器" required="required" prop="accessories.r_charge_housekeeper" borderBottom labelWidth="100" ref="item1">
  183. <uv-input v-model="formdata.accessories.r_charge_housekeeper" border="none" placeholder="请输入主电充电器数量"></uv-input>
  184. </uv-form-item>
  185. <uv-form-item label="手簿" required="required" prop="accessories.r_charging_head" borderBottom labelWidth="100" ref="item1">
  186. <uv-input v-model="formdata.accessories.r_charging_head" border="none" placeholder="请输入手簿数量"></uv-input>
  187. </uv-form-item>
  188. <uv-form-item label="手簿夹" required="required" prop="accessories.r_hand_book_holder" borderBottom labelWidth="100" ref="item1">
  189. <uv-input v-model="formdata.accessories.r_hand_book_holder" border="none" placeholder="请输入手簿夹数量"></uv-input>
  190. </uv-form-item>
  191. <uv-form-item label="手簿笔" required="required" prop="accessories.r_hand_book_pen" borderBottom labelWidth="100" ref="item1">
  192. <uv-input v-model="formdata.accessories.r_hand_book_pen" border="none" placeholder="请输入手簿笔数量"></uv-input>
  193. </uv-form-item>
  194. <uv-form-item label="手簿充电头" required="required" prop="accessories.r_charging_head" borderBottom labelWidth="100" ref="item1">
  195. <uv-input v-model="formdata.accessories.r_charging_head" border="none" placeholder="请输入手簿充电头数量"></uv-input>
  196. </uv-form-item>
  197. <uv-form-item label="手电" required="required" prop="accessories.r_flashlight" borderBottom labelWidth="100" ref="item1">
  198. <uv-input v-model="formdata.accessories.r_flashlight" border="none" placeholder="请输入手电数量"></uv-input>
  199. </uv-form-item>
  200. <uv-form-item label="连接头" required="required" prop="accessories.r_connection_head" borderBottom labelWidth="100" ref="item1">
  201. <uv-input v-model="formdata.accessories.r_connection_head" border="none" placeholder="请输入连接头数量"></uv-input>
  202. </uv-form-item>
  203. <uv-form-item label="测高片" required="required" prop="accessories.r_height_measuring_plate" borderBottom labelWidth="100" ref="item1">
  204. <uv-input v-model="formdata.accessories.r_height_measuring_plate" border="none" placeholder="请输入测高片数量"></uv-input>
  205. </uv-form-item>
  206. <uv-form-item label="长天线" required="required" prop="accessories.r_long_antenna" borderBottom labelWidth="100" ref="item1">
  207. <uv-input v-model="formdata.accessories.r_long_antenna" border="none" placeholder="请输入长天线数量"></uv-input>
  208. </uv-form-item>
  209. <uv-form-item label="短天线" required="required" prop="accessories.r_short_antenna" borderBottom labelWidth="100" ref="item1">
  210. <uv-input v-model="formdata.accessories.r_short_antenna" border="none" placeholder="请输入短天线数量"></uv-input>
  211. </uv-form-item>
  212. <uv-form-item label="说明书" required="required" prop="accessories.r_instruction_manual" borderBottom labelWidth="100" ref="item1">
  213. <uv-input v-model="formdata.accessories.r_instruction_manual" border="none" placeholder="请输入说明书数量"></uv-input>
  214. </uv-form-item>
  215. <uv-form-item label="光盘" required="required" prop="accessories.r_cdrow" borderBottom labelWidth="100" ref="item1">
  216. <uv-input v-model="formdata.accessories.r_cdrow" border="none" placeholder="请输入光盘数量"></uv-input>
  217. </uv-form-item>
  218. <uv-form-item label="USB线" required="required" prop="accessories.r_usb" borderBottom labelWidth="100" ref="item1">
  219. <uv-input v-model="formdata.accessories.r_usb" border="none" placeholder="请输入主机电池数量"></uv-input>
  220. </uv-form-item>
  221. </view>
  222. <uv-form-item label="备注" :required="formdata.purpose == 1" prop="remarks" borderBottom labelWidth="80" ref="item3">
  223. <uv-textarea placeholder="请填写其他配件以及其他要求" v-model="formdata.remarks" count></uv-textarea>
  224. </uv-form-item>
  225. <view class="uanze_title">
  226. <view class="xuanze_title">
  227. 电子签字
  228. </view>
  229. <button type="primary" size="mini" @click="goSign('worker1')" class="add_anniu">去签名</button>
  230. </view>
  231. <!-- <image style="width: 200px; height: 200px; background-color: #eeeeee;" @load='imgOnCan' @error='imgOnError' :src="signSrc" v-if="signShow"></image> -->
  232. <image style="width: 200px; height: 200px; background-color: #eeeeee;" :src="signSrc" v-show="signShow" @load='imgOnCan' @error='imgOnError'></image>
  233. </uv-form>
  234. <uv-popup ref="popup" :close-on-click-overlay="false" >
  235. <view style="width:94vw; height:auto;">
  236. <view class="" style="margin: 20rpx 20rpx;">
  237. <view class="" style="margin:20rpx 0;font-weight: bold;">
  238. 仪器借用协议:
  239. </view>
  240. <view class="" style="max-height: 60vh;overflow-y:auto">
  241. <!-- <rich-text style="max-height: 60vh;" :nodes="this.protocolText.data"></rich-text> -->
  242. <rich-text :nodes="this.protocolText.data" id="protocolData"></rich-text>
  243. </view>
  244. </view>
  245. <button type="error" @click="closePo" style="margin: 20rpx 20rpx;">关闭</button>
  246. <button type="primary" @click="submit" :disabled="isChoose" style="margin: 20rpx 20rpx;">
  247. <uv-count-down
  248. ref="countDown"
  249. :time="5* 1000"
  250. format="ss"
  251. :autoStart="false"
  252. millisecond
  253. @change="onChange"
  254. @finish="getFinish"
  255. v-if="isChoose"
  256. >
  257. </uv-count-down>
  258. 同意
  259. </button>
  260. </view>
  261. </uv-popup>
  262. <uv-button type="primary" text="提交" customStyle="margin-top: 50px" @click="submitON"></uv-button>
  263. <uv-button type="error" text="重置" customStyle="margin-top: 10px;margin-bottom: 30rpx;" @click="reset"></uv-button>
  264. </view>
  265. </view>
  266. </view>
  267. </template>
  268. <script>
  269. import { padZero, timeFormat, toast } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
  270. import { chinese } from '@/uni_modules/uv-ui-tools/libs/function/test.js';
  271. import { requestApi , requestFileApi } from '@/api/request.js';
  272. import { toRaw } from '@vue/reactivity';
  273. export default {
  274. onLoad(){
  275. uni.$on('qing',data =>{
  276. console.log(data)
  277. this.pImg = data
  278. })
  279. uni.$on('q-sign',data =>{
  280. console.log('tempFilePath',data);
  281. this.signSrc = data.tempFilePath;
  282. const ctx2 = uni.createCanvasContext('myCanvasr');
  283. ctx2.drawImage(data.tempFilePath, 0, 0, 200, 200);
  284. ctx2.drawImage(this.pImg.tempFilePath, 0, 0, 595, 1000);
  285. ctx2.draw(true,
  286. uni.canvasToTempFilePath({
  287. canvasId: 'myCanvasr',
  288. success: (res) => {
  289. console.log(res.tempFilePath)
  290. }
  291. })
  292. );
  293. // 获取拼接后的图片路径
  294. const res = requestFileApi(
  295. '/admin/ajax/upload?server=1',
  296. data.tempFilePath
  297. ).then(d => {
  298. var responseObject = JSON.parse(d);
  299. var fileUrl = responseObject.data.file.url;
  300. // 传图片接口;
  301. const returndata = requestApi(
  302. 'admin/ajax/saveSign?server=1',
  303. {
  304. sign:fileUrl
  305. },
  306. 'POST'
  307. ).then(ret => {
  308. this.signShow = true;
  309. })
  310. })
  311. })
  312. // 获取电子签字
  313. const returndata = requestApi(
  314. 'admin/ajax/getSign?server=1','GET'
  315. ).then(ret => {
  316. console.log(ret)
  317. if(ret.code == 1){
  318. this.signSrc = "https://yxy.glut.cc/" + ret.data.file.sign
  319. if(ret.data.file.sign !== ''){
  320. this.signShow = true
  321. }
  322. }
  323. })
  324. const getUserData = requestApi(
  325. 'admin/borrow.BorrowApp/add?server=1','GET'
  326. ).then(ret => {
  327. console.log(ret)
  328. if(ret.code == 1){
  329. this.formdata.username = ret.data.username
  330. this.formdata.mobile = ret.data.mobile
  331. }
  332. })
  333. const getAssetData = requestApi(
  334. '/admin/asset.AssetInformation/getDataSelect?server=1','GET'
  335. ).then(ret => {
  336. if(ret.code == 1){
  337. console.log( ret.data)
  338. this.candidates = ret.data;
  339. }else{
  340. toast(' 仪器列表获取失败,请检查网络!!')
  341. }
  342. })
  343. const getProtocol = requestApi(
  344. '/admin/borrow.BorrowApply/getProtocol?server=1','GET'
  345. ).then(ret => {
  346. if(ret.code == 1){
  347. this.protocolText = ret.data;
  348. const text = ret.data.data1;
  349. const ctx = wx.createCanvasContext('myCanvasP');
  350. ctx.font = '20px Microsoft YaHei';
  351. ctx.textAlign = 'left';
  352. ctx.fillStyle = '#000000';
  353. ctx.fillText("桂林理工大学测绘地理信息学院仪器借用承诺书",83, 50);
  354. ctx.font = '15px Microsoft YaHei';
  355. const strArr = Array.from(text);
  356. let line = '';
  357. let y = 120;
  358. strArr.forEach(char => {
  359. const testLine = line + char;
  360. const metrics = ctx.measureText(testLine);
  361. const testWidth = metrics.width;
  362. if (testWidth + 24 > 555) {
  363. if (line.trim() === '') {
  364. line += char;
  365. } else {
  366. ctx.fillText(line, 33, y);
  367. line = char;
  368. y += 20;
  369. }
  370. } else {
  371. line += char;
  372. }
  373. });
  374. if (line.trim() !== '') {
  375. ctx.fillText(line, 33, y);
  376. }
  377. ctx.draw(true, () => {
  378. uni.canvasToTempFilePath({
  379. x: 0,
  380. y: 0,
  381. width: 595,
  382. height: 842,
  383. destWidth: 595,
  384. destHeight: 842,
  385. canvasId: 'myCanvasP',
  386. success: function(res) {
  387. console.log(res.tempFilePath);
  388. // 假设uni.$emit是您项目中用于事件通信的方法
  389. uni.$emit('qing', { tempFilePath: res.tempFilePath });
  390. }
  391. });
  392. });
  393. }
  394. })
  395. },
  396. onUnload(){
  397. uni.$off('q-sign'); //移除监听事件
  398. },
  399. data() {
  400. return {
  401. imageSrc:'',
  402. pImg:'',
  403. is_w: false,
  404. is_q: false,
  405. is_s: false,
  406. is_r: false,
  407. signShow : false,
  408. signSrc : '',
  409. isShow: false,
  410. isChoose: true,
  411. protocolText:'',
  412. inputValue_json: '',
  413. candidates:[],
  414. formdata: {
  415. username: '',
  416. mobile: '',
  417. purpose: 0,
  418. borrow_time :'',
  419. expected_end_time:'',
  420. borrow_reason: '',
  421. remarks: '',
  422. asset: [
  423. {
  424. model: '',
  425. origin: '',
  426. num: '',
  427. origins : []
  428. },
  429. ],
  430. accessories: {
  431. w_battery : 0,
  432. w_remote_control: 0,
  433. w_remote_control_battery: 0,
  434. w_charge_housekeeper: 0,
  435. w_propeller: 0,
  436. w_sd: 0,
  437. q_battery: 0,
  438. q_charge_housekeeper: 0,
  439. q_tripod: 0,
  440. q_prism: 0,
  441. q_center_bar: 0,
  442. q_data_line: 0,
  443. s_battery: 0,
  444. s_charge_housekeeper: 0,
  445. s_adjustment_wrench: 0,
  446. s_data_line: 0,
  447. s_rain_proof_cloth: 0,
  448. s_level_gauge: 0,
  449. s_tripod: 0,
  450. s_ruler_pad: 0,
  451. r_battery: 0,
  452. r_charge_housekeeper: 0,
  453. r_charging_head: 0,
  454. r_hand_book: 0,
  455. r_hand_book_holder: 0,
  456. r_hand_book_pen: 0,
  457. r_usb: 0,
  458. r_flashlight: 0,
  459. r_cdrow: 0,
  460. r_long_antenna: 0,
  461. r_short_antenna: 0,
  462. r_height_measuring_plate: 0,
  463. r_connection_head: 0,
  464. r_instruction_manual: 0
  465. },
  466. },
  467. rules: {
  468. 'username': [{
  469. required: true,
  470. message: '此为必填字段',
  471. // blur和change事件触发检验
  472. trigger: ['blur', 'change'],
  473. },
  474. {
  475. // 此为同步验证,可以直接返回true或者false,如果是异步验证,稍微不同,见下方说明
  476. validator: (rule, value, callback) => {
  477. // 调用uView自带的js验证规则,详见:https://www.uviewui.com/js/test.html
  478. return chinese(value);
  479. },
  480. message: "姓名必须为中文",
  481. // 触发器可以同时用blur和change,二者之间用英文逗号隔开
  482. trigger: ["change", "blur"],
  483. }],
  484. 'mobile': [{
  485. required: true,
  486. message: '此为必填字段',
  487. // blur和change事件触发检验
  488. trigger: ['blur', 'change'],
  489. },
  490. {
  491. pattern: /^[1][3,4,5,7,8][0-9]{9}$/,
  492. // 正则检验前先将值转为字符串
  493. transform(value) {
  494. return String(value);
  495. },
  496. message: '请正确输入手机号码'
  497. }],
  498. 'boorow_time': [{
  499. required: true,
  500. message: '请选择预计领取时间',
  501. // blur和change事件触发检验
  502. trigger: ['blur', 'change'],
  503. }],
  504. 'expected_end_time': [{
  505. required: true,
  506. message: '请选择预计归还时间',
  507. // blur和change事件触发检验
  508. trigger: ['blur', 'change'],
  509. }],
  510. 'borrow_reason': [{
  511. required: true,
  512. message: '请填写借取理由',
  513. // blur和change事件触发检验
  514. trigger: ['blur', 'change'],
  515. }]
  516. },
  517. dynamicFormData: {
  518. quantity: '',
  519. instrument:'',
  520. domains:{quantity: {},instrument:{}}
  521. },
  522. dynamicLists: [],
  523. }
  524. },
  525. onReady() {
  526. // 如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则
  527. this.$refs.form1.setRules(this.rules)
  528. },
  529. methods: {
  530. imgOnCan(){
  531. // console.log(123)
  532. this.signShow = true;
  533. },
  534. imgOnError(){
  535. console.log(456)
  536. this.signShow = false;
  537. },
  538. goSign(worker){
  539. uni.navigateTo({
  540. url:'/uni_modules/q-sign/pages/q-sign?name=' + worker
  541. })
  542. },
  543. // 仪器选择
  544. openPicker() {
  545. this.$refs.picker.open();
  546. },
  547. confirm(e) {
  548. // console.log('confirm', e.value[0]);
  549. this.dynamicFormData.instrument = e.value[0]
  550. },
  551. showDateSelect() {
  552. this.$refs.datetimePicker.open();
  553. this.hideKeyboard();
  554. },
  555. showDateSelectBorrow() {
  556. this.$refs.datetimePicker1.open();
  557. this.hideKeyboard();
  558. },
  559. showDateconfirm(e) {
  560. this.formdata.expected_end_time = this.formatterResult(e.value, e.mode)
  561. },
  562. showDateconfirmBorrrow(e) {
  563. console.log(e)
  564. this.formdata.borrow_time = this.formatterResult(e.value, e.mode)
  565. },
  566. formatter(type, value) {
  567. if (type === 'year') {
  568. return `${value}年`
  569. }
  570. if (type === 'month') {
  571. return `${value}月`
  572. }
  573. if (type === 'day') {
  574. return `${value}日`
  575. }
  576. return value
  577. },
  578. formatterResult(time, mode) {
  579. switch (mode) {
  580. case 'datetime':
  581. return timeFormat(time, 'yyyy-mm-dd hh:MM')
  582. case 'date':
  583. return timeFormat(time, 'yyyy-mm-dd')
  584. case 'year-month':
  585. return timeFormat(time, 'yyyy-mm')
  586. case 'time':
  587. return toast(time)
  588. case 'year':
  589. return timeFormat(time, 'yyyy')
  590. default:
  591. return ''
  592. }
  593. },
  594. // 仪器名称及数量
  595. addasset() {
  596. this.formdata.asset.push({
  597. model: '',
  598. origin: '',
  599. num: '',
  600. origins : []
  601. })
  602. },
  603. onDelArrayItem(idx){
  604. this.formdata.asset.splice(idx, 1)
  605. },
  606. openPicker2() {
  607. console.log(123)
  608. this.$refs.picker2.open();
  609. },
  610. confirm2(e) {
  611. console.log('confirm', e.value[0]);
  612. },
  613. del(id) {
  614. let index = this.dynamicLists.findIndex(v => v.id === id)
  615. this.dynamicLists.splice(index, 1)
  616. },
  617. closePo(){
  618. if(this.isChoose){
  619. this.$refs.countDown.reset();
  620. }
  621. this.$refs.popup.close();
  622. },
  623. submitON(){
  624. if(!this.signShow){
  625. toast(' 请检查签名!!')
  626. return false;
  627. }
  628. this.$refs.form1.validate().then(res => {
  629. this.$refs.popup.open();
  630. }).catch(errors => {
  631. toast(' 请重新填写!!')
  632. })
  633. if(this.isChoose){
  634. this.$refs.countDown.start();
  635. }
  636. },
  637. getFinish(){
  638. this.isChoose = false;
  639. },
  640. // 提交
  641. submit() {
  642. wx.showLoading({
  643. title: '加载中',
  644. })
  645. // 如果有错误,会在catch中返回报错信息数组,校验通过则在then中返回true
  646. const d = requestApi(
  647. '/admin/borrow.BorrowApp/add?server=1',
  648. {data : toRaw(this.formdata)},
  649. 'POST'
  650. ).then(d => {
  651. if(d.code === 1){
  652. wx.navigateBack({
  653. delta:1
  654. })
  655. }else{
  656. toast(d.msg)
  657. }
  658. wx.hideLoading()
  659. })
  660. },
  661. // 重置
  662. reset() {
  663. const validateList = ['username', '', '', '', '',
  664. ''
  665. ]
  666. this.$refs.form1.resetFields()
  667. this.$refs.form1.clearValidate()
  668. setTimeout(() => {
  669. this.$refs.form1.clearValidate(validateList)
  670. // 或者使用 this.$refs.form1.clearValidate()
  671. }, 10)
  672. },
  673. hideKeyboard() {
  674. uni.hideKeyboard()
  675. },
  676. doss() {
  677. this.isShow = true;
  678. },
  679. close() {
  680. this.isShow = false;
  681. },
  682. save(val) {
  683. this.isShow = false;
  684. this.img1 = this.$refs.hello.signImage;
  685. // console.log('微信小程序产生的',this.img1);
  686. }
  687. },
  688. watch:{
  689. formdata:{
  690. handler(val){
  691. console.log(val)
  692. this.is_w = val.asset.some(asset => asset.model.includes('无人机'));
  693. this.is_q = val.asset.some(asset => asset.model.includes('全站仪'));
  694. this.is_s = val.asset.some(asset => asset.model.includes('水准仪'));
  695. this.is_r = val.asset.some(asset => asset.model.includes('RTK')|| asset.model.includes('GNSS'));
  696. },
  697. deep:true
  698. },
  699. }
  700. }
  701. </script>
  702. <style lang="less">
  703. .add_anniu {
  704. float: left;
  705. background-color: #2d8cf0 !important;
  706. }
  707. .xuanze_title {
  708. padding: 0 10rpx;
  709. border-left: 10rpx solid #2d8cf0;
  710. float: left;
  711. margin-right: 20rpx;
  712. }
  713. .uanze_title {
  714. height: 30px;
  715. margin-top: 20rpx;
  716. line-height: 30px;
  717. }
  718. .form-item {
  719. display: flex;
  720. align-items: center;
  721. }
  722. .button {
  723. display: flex;
  724. align-items: center;
  725. height: 35px;
  726. margin-left: 10px;
  727. }
  728. </style>