酷炫直播运营系统小程序版本

addExpenseForm.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <view class="con">
  3. <!-- 个人信息-->
  4. <view class="infoTop">
  5. <view class="flex-bewteen">
  6. <view>
  7. <text>公司: </text>
  8. <text>{{top_info.company_subject_name?top_info.company_subject_name:'-'}}</text>
  9. </view>
  10. </view>
  11. <view class="flex-bewteen tMar14">
  12. <view>
  13. <text>部门: </text>
  14. <text>{{top_info.department_name?top_info.department_name:'-'}}</text>
  15. </view>
  16. <view>
  17. <text>经手人: </text>
  18. <text>{{top_info.reimburse_name?top_info.reimburse_name:'-'}}</text>
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 编辑区域-->
  23. <view v-if="editAreaShow">
  24. <view v-for="(d,didx) in danFromList" :key="didx" class="edit_item">
  25. <view>
  26. 报销单
  27. <text v-if="danFromList&&danFromList.length>1">{{didx+1}}</text>
  28. <text class="iconfont icon-butongguo_icon f26 lMar8" v-if="danFromList&&danFromList.length>1" @click="deleDan(didx,d.id)"></text>
  29. </view>
  30. <view class="edit_item_row flex-bewteen">
  31. <text>事由说明</text>
  32. <text class="note">*</text>
  33. <!-- pageOpt.reason-->
  34. <input v-model="d.reason" :disabled="onlySee" type="text" class="ipt_box" placeholder="请输入事由说明" style="width: 73%" />
  35. </view>
  36. <view class="edit_item_row flex-bewteen">
  37. <text>下班时间</text>
  38. <text class="note">*</text>
  39. <uni-datetime-picker class="ecpensePicker" type="datetime" :end="tomorrw" :clear-icon="false" :border="false" :disabled="onlySee" v-model="d.off_time" />
  40. </view>
  41. <view class="edit_item_row">
  42. <view class="flex-bewteen">
  43. <text>出发</text>
  44. <text class="note">*</text>
  45. <uni-datetime-picker class="ecpensePicker" type="datetime" :end="tomorrw" :clear-icon="false" :border="false" :disabled="onlySee" v-model="d.start_time" />
  46. </view>
  47. <view><input v-model="d.start_site" :disabled="onlySee" type="text" class="ipt_box" placeholder="请输入出发地点" /></view>
  48. </view>
  49. <view class="edit_item_row">
  50. <view class="flex-bewteen">
  51. <text>到达</text>
  52. <text class="note">*</text>
  53. <uni-datetime-picker class="ecpensePicker" type="datetime" :clear-icon="false" :end="tomorrw" :border="false" :disabled="onlySee" v-model="d.end_time" />
  54. </view>
  55. <view><input v-model="d.end_site" type="text" :disabled="onlySee" class="ipt_box" placeholder="请输入到达地点" /></view>
  56. </view>
  57. <view class="edit_item_row">
  58. <view class="flex-bewteen">
  59. <text>交通工具</text>
  60. <text class="note">*</text>
  61. <picker class="ex_picker" :disabled="onlySee" v-model="d.car_type" :range="car_type_option" @change="bindPickerChange($event,didx)" style="width: 54%">
  62. <view class="uni-input">{{car_type_option[d.car_type]}}</view>
  63. </picker>
  64. </view>
  65. <view class="flex-bewteen">
  66. <text>金额</text>
  67. <text class="note">*</text>
  68. <input style="width: 60%" v-model="d.amount" :disabled="onlySee" type="text" class="ipt_box" placeholder="请输入金额" />
  69. </view>
  70. </view>
  71. <view class="edit_item_row">
  72. <view @click="passFeechange(didx)">
  73. <checkbox class="expense_check" style="transform:scale(0.7)" :value="d.passing_is" :checked="d.passing_is" :disabled="onlySee" />过路费
  74. </view>
  75. <view class="flex-bewteen" v-if="d.passing_is">
  76. <text>金额</text> <text class="note">*</text>
  77. <input style="width: 60%" v-model="d.toll_fee" :disabled="onlySee" type="text" class="ipt_box" placeholder="请输入金额" />
  78. </view>
  79. </view>
  80. <view style="height: 3px;background: #3D4453;margin: 30rpx 0 20rpx;"></view>
  81. <view class="flex-bewteen">
  82. <text>备注</text> <textarea v-model="d.remark" :disabled="onlySee" placeholder="请输入备注" class="ex_textarea" placeholder-style="line-height: 60rpx;padding:10rpx" />
  83. </view>
  84. </view>
  85. </view>
  86. <!-- 添加框 -->
  87. <view class="plusBox" @click="addFormList" v-if="(optisEdit == 1&&infoTop&&infoTop.if_can_add_new == 1) || optisEdit == 0">
  88. 添加报销单
  89. <text class="iconfont icon-tianjia_icon f26 lMar8"></text>
  90. </view>
  91. <!--操作按钮 -->
  92. <view @click="liveAdd" class="save" v-if="!onlySee">保存</view>
  93. <wm-watermark :text="real_name"></wm-watermark>
  94. </view>
  95. </template>
  96. <script>
  97. export default {
  98. data () {
  99. return {
  100. real_name: '',
  101. del_ids: [], // 删除的id集合
  102. tomorrw: this.$getDay(0, false) + ' 23:59:59',//今天以后不能选
  103. pageOpt: {},
  104. infoTop: {},
  105. editAreaShow: false,
  106. goTime: '',
  107. goAdd: '',
  108. endTime: '',
  109. endAdd: '',
  110. car_type_option: ['出租车', '网约车'], //1,2
  111. danFromList: [ //新增报销初始化字段们
  112. // {
  113. // start_time: "",
  114. // end_time: "",
  115. // start_site: "",
  116. // end_site: "",
  117. // amount: "",
  118. // passing_is: false,
  119. // toll_fee: "",
  120. // remark: "",
  121. // reason: "",
  122. // off_time: "",
  123. // car_type:0,//传值时,此值加1就是后台需要的参数 ,出租车1,网约车2
  124. // }
  125. ],
  126. data_add: [],
  127. emptyFlag: false,//判断是否有空值,true有
  128. onlySee: false,//仅查看不能操作
  129. optisEdit: 0,
  130. top_info: {},
  131. page:'',
  132. }
  133. },
  134. async onLoad(option) {
  135. await this.$onLaunched;
  136. this.real_name = uni.getStorageSync('userInfo').info.real_name;
  137. this.get_userInfoReback()
  138. this.pageOpt = JSON.parse(decodeURIComponent(option.item))
  139. this.optisEdit = option.isEdit
  140. this.page = option.page
  141. if (this.optisEdit == 1 || this.optisEdit == 2) {
  142. this.reBackInfo()
  143. }
  144. this.onlySee = false
  145. if (this.optisEdit == 2) {
  146. this.onlySee = true
  147. }
  148. },
  149. methods: {
  150. get_userInfoReback () {
  151. this.$req(this.$api.userReiInfoDetail, 'get', {}, (res) => {
  152. if (res && res.errno == 0) {
  153. this.top_info = res.rst
  154. }
  155. })
  156. },
  157. //判断是否是空值
  158. judge_empty_Data () {
  159. this.emptyFlag = false
  160. this.data_add = []
  161. let old_id = []
  162. if (this.danFromList && this.danFromList.length == 0) {
  163. uni.showToast({
  164. title: '添加报销单后可提交',
  165. icon: 'none',
  166. duration: 2000
  167. })
  168. return false
  169. }
  170. this.danFromList.forEach((i) => {
  171. if (
  172. i.off_time == '' ||
  173. i.start_time == '' ||
  174. i.end_time == '' ||
  175. i.start_site == '' ||
  176. i.end_site == '' ||
  177. i.amount == ''
  178. ) {
  179. this.emptyFlag = true
  180. } else {
  181. if (i.id) {
  182. old_id.push(i.id)
  183. }
  184. this.data_add.push({
  185. is_new: old_id.indexOf(i.id) == -1 ? 1 : 0,
  186. id: i.id ? i.id : 0,
  187. off_time: i.off_time,
  188. start_time: i.start_time,
  189. end_time: i.end_time,
  190. start_site: i.start_site,
  191. end_site: i.end_site,
  192. car_type: Number(i.car_type) + 1,
  193. amount: i.amount,
  194. toll_fee: i.passing_is ? i.toll_fee : null,
  195. remark: i.remark,
  196. reason: i.reason
  197. })
  198. }
  199. })
  200. },
  201. reBackInfo () { //编辑回显
  202. this.editAreaShow = true
  203. uni.showLoading({title: '加载中'});
  204. this.$req(this.$api.reimbDetail_else, 'get', {
  205. id: this.pageOpt.id
  206. }, (res) => {
  207. uni.hideLoading()
  208. if (res && res.errno == 0) {
  209. this.infoTop = res.rst.info
  210. let arr = res.rst
  211. if (arr.toll_fee) {
  212. arr.passing_is = true
  213. } else {
  214. arr.passing_is = false
  215. }
  216. arr.car_type = Number(arr.car_type) - 1
  217. this.danFromList.push(arr)
  218. console.log(this.danFromList, 'danFromList');
  219. } else {
  220. uni.showToast({
  221. title: res.err,
  222. icon: 'none',
  223. duration: 2000
  224. })
  225. }
  226. },()=>{
  227. uni.hideLoading()
  228. })
  229. },
  230. //保存
  231. liveAdd () {
  232. this.judge_empty_Data()
  233. if (this.emptyFlag) {
  234. uni.showToast({
  235. title: '以上均为必填项',
  236. icon: 'none',
  237. duration: 2000
  238. })
  239. return false
  240. }
  241. this.$show_init_loading()
  242. let api = this.$api.else_reimb_add //首次添加
  243. let param = {
  244. data: JSON.stringify(this.data_add)
  245. }
  246. if (this.optisEdit == 1) { //编辑
  247. api = this.$api.else_reimb_edit
  248. param = {
  249. id: this.danFromList[0].id,
  250. start_time: this.danFromList[0].start_time,
  251. end_time: this.danFromList[0].end_time,
  252. start_site: this.danFromList[0].start_site,
  253. end_site: this.danFromList[0].end_site,
  254. car_type: Number(this.danFromList[0].car_type) + 1,
  255. toll_fee: this.danFromList[0].passing_is ? this.danFromList[0].toll_fee : null,
  256. amount: this.danFromList[0].amount,
  257. off_time: this.danFromList[0].off_time,
  258. reason: this.danFromList[0].reason,
  259. remark: this.danFromList[0].remark,
  260. }
  261. }
  262. this.$req(api, 'post', param, (res) => {
  263. if (res && res.errno == 0) {
  264. let _this = this;
  265. let pages = getCurrentPages(); // 当前页面
  266. let beforePage = pages[pages.length - 2]; // 上一页
  267. uni.navigateBack({
  268. success: function () {
  269. beforePage.onLoad({ page: 'reimbursementPage'}); // 执行上一页的onLoad方法
  270. }
  271. });
  272. }else{
  273. uni.showToast({
  274. title: res.err,
  275. icon: 'none',
  276. duration: 2000
  277. })
  278. }
  279. this.$hide_init_loading()
  280. })
  281. },
  282. bindPickerChange: function (e, idx) {
  283. this.danFromList[idx].car_type = e.target.value
  284. },
  285. passFeechange: function (idx) {
  286. this.danFromList[idx].passing_is = !this.danFromList[idx].passing_is
  287. },
  288. addFormList () { //新增报销单
  289. if (!this.editAreaShow) {
  290. this.editAreaShow = true
  291. }
  292. let item = {
  293. off_time: '',
  294. start_time: "",
  295. end_time: "",
  296. start_site: "",
  297. end_site: "",
  298. amount: "",
  299. passing_is: false,
  300. toll_fee: "",
  301. remark: "",
  302. reason: "",
  303. car_type: 0,//传值时,此值加1就是后台需要的参数 ,出租车1,网约车2
  304. }
  305. this.danFromList.push(item)
  306. },
  307. deleDan (i, id) { //删除报销单
  308. if (id) {
  309. this.del_ids = []
  310. this.del_ids.push(id)
  311. }
  312. this.danFromList.splice(i, 1)
  313. },
  314. }
  315. }
  316. </script>
  317. <style lang="scss" scoped>
  318. .con {
  319. padding: 26rpx;
  320. font-size: 26rpx;
  321. background: #242a37;
  322. }
  323. .infoTop {
  324. background: linear-gradient(160deg, #87b5ff 0%, #4f7eff 100%);
  325. border-radius: 6rpx;
  326. padding: 22rpx 30rpx;
  327. }
  328. .plusBox {
  329. text-align: center;
  330. background: #3d4453;
  331. height: 100rpx;
  332. line-height: 100rpx;
  333. font-size: 24rpx;
  334. width: 100%;
  335. margin-top: 24rpx;
  336. }
  337. .save {
  338. margin: 40rpx auto;
  339. background-color: #5b80f4;
  340. width: 25%;
  341. border-radius: 10rpx;
  342. height: 80rpx;
  343. line-height: 80rpx;
  344. text-align: center;
  345. font-size: 28rpx;
  346. }
  347. .edit_item {
  348. background: #373e4e;
  349. border-radius: 6rpx;
  350. padding: 40rpx 30rpx;
  351. margin-top: 24rpx;
  352. .note {
  353. color: #ff2b2b;
  354. margin-right: 8rpx;
  355. }
  356. .edit_item_row {
  357. display: flex;
  358. align-items: center;
  359. justify-content: space-between;
  360. margin-top: 20rpx;
  361. .ipt_box {
  362. background: #1c222e;
  363. height: 60rpx;
  364. border-radius: 8rpx;
  365. line-height: 60rpx;
  366. padding: 0 10rpx;
  367. }
  368. }
  369. .edit_item_row > view:nth-child(1) {
  370. width: 55%;
  371. }
  372. .edit_item_row > view:nth-child(2) {
  373. width: 43%;
  374. }
  375. .ex_picker {
  376. background: #1c222e;
  377. height: 60rpx;
  378. border-radius: 8rpx;
  379. line-height: 60rpx;
  380. padding: 0 10rpx;
  381. width: 60%;
  382. }
  383. .ex_textarea {
  384. background: #1c222e;
  385. height: 120rpx;
  386. border-radius: 8rpx;
  387. line-height: 40rpx;
  388. padding: 10rpx;
  389. width: 84%;
  390. }
  391. }
  392. </style>