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

addExpenseForm.vue 11KB

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