综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

borrowDetail.vue 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <!--
  2. * @Author: ysh
  3. * @Date: 2025-02-27 10:43:04
  4. * @LastEditors: Please set LastEditors
  5. * @LastEditTime: 2025-02-28 16:27:00
  6. -->
  7. <template>
  8. <view class="container">
  9. <u-button type="primary" @click="showAddPopup = true">+ 新增借款项</u-button>
  10. <!-- 列表标题 -->
  11. <view class="list-header">
  12. <text class="header-item">开支项目</text>
  13. <text class="header-item amount">申请金额</text>
  14. </view>
  15. <!-- 数据列表 -->
  16. <view class="list-box" v-for="(item, index) in detailList" :key="item.borrowDetailId">
  17. <view class="indexs">
  18. <text>{{ index + 1 }}</text>
  19. </view>
  20. <view class="list-item">
  21. <view class="item-left">
  22. <text class="item-title">{{ item.borrowItem }}</text>
  23. <text class="item-sub">
  24. ¥{{ item.price }} × {{ item.quantity }}{{ item.unit }}
  25. </text>
  26. </view>
  27. <view class="item-right">
  28. <text class="total-amount">¥{{ item.applyAmount }}</text>
  29. </view>
  30. </view>
  31. <!-- <view class="fg-amount">
  32. <text>分管领导审核金额</text>
  33. <uni-easyinput v-model="item.managerAmount" placeholder="请输入审核金额" />
  34. </view> -->
  35. <view class="box-button">
  36. <u-button size="normal" icon="edit-pen">修改</u-button>
  37. <u-button size="normal" icon="trash" @click="deleteItem(item)">删除</u-button>
  38. </view>
  39. </view>
  40. <!-- 借款弹窗 -->
  41. <view v-if="showAddPopup" class="add-popup">
  42. <view class="popup-content">
  43. <text class="popup-title">新增借款项</text>
  44. <uni-forms ref="form" :modelValue="newItem" :rules="rules" label-position="top" label-width="150"
  45. class="custom-form">
  46. <uni-forms-item label="开支项目" name="borrowItem" required class="form-item">
  47. <uni-easyinput v-model="newItem.borrowItem" placeholder="请输入开支项目" />
  48. </uni-forms-item>
  49. <uni-forms-item label="单位" name="unit" required class="form-item">
  50. <uni-easyinput v-model="newItem.unit" placeholder="请输入单位" />
  51. </uni-forms-item>
  52. <uni-forms-item label="单价" name="price" required class="form-item">
  53. <uni-easyinput type="number" v-model="newItem.price" placeholder="请输入单价" />
  54. </uni-forms-item>
  55. <uni-forms-item label="数量" name="quantity" required class="form-item">
  56. <uni-easyinput type="number" v-model="newItem.quantity" placeholder="请输入数量" />
  57. </uni-forms-item>
  58. <uni-forms-item label="合计">
  59. <text>{{ getTotal() }}</text>
  60. </uni-forms-item>
  61. </uni-forms>
  62. <view class="popup-buttons">
  63. <u-button @click="cancelAdd">取消</u-button>
  64. <u-button type="primary" class="confirm" @click="confirmAdd">确认添加</u-button>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. import { listBorrowDetail, addBorrowDetail, updateBorrowDetail, delBorrowDetail, delBorrowDetailByDetailId } from "@/api/oa/borrow/borrowDetail";
  72. import uButton from '../../../uni_modules/uview-ui/components/u-button/u-button.vue';
  73. export default {
  74. components: { uButton },
  75. props: {
  76. borrowId: String
  77. },
  78. data() {
  79. return {
  80. detailList: [],
  81. showAddPopup: false,
  82. newItem: {
  83. borrowItem: '',
  84. unit: '',
  85. price: '',
  86. quantity: '',
  87. applyAmount: 0
  88. },
  89. rules: {},
  90. errorMessage: '',
  91. }
  92. },
  93. created() {
  94. },
  95. watch: {
  96. borrowId() {
  97. this.initList();
  98. }
  99. },
  100. methods: {
  101. initList() {
  102. listBorrowDetail({ pageSize: 999, borrowId: this.borrowId }).then(res => {
  103. if (res.rows.length != 0) {
  104. this.detailList = res.rows
  105. console.log(res.rows);
  106. }
  107. });
  108. },
  109. // 确认添加
  110. confirmAdd() {
  111. this.$refs.form.validate().then(res => {
  112. console.log('表单数据信息:', res);
  113. res.borrowId = this.borrowId;
  114. res.applyAmount = this.getTotal();
  115. addBorrowDetail(res);
  116. // this.detailList.unshift({
  117. // borrowId: this.borrowId,
  118. // borrowItem: this.newItem.borrowItem,
  119. // unit: this.newItem.unit,
  120. // price: Number(this.newItem.price),
  121. // quantity: Number(this.newItem.quantity),
  122. // applyAmount: Number(this.newItem.price) * Number(this.newItem.quantity)
  123. // })
  124. // console.log(this.detailList);
  125. this.clearForm()
  126. this.showAddPopup = false
  127. this.initList();
  128. })
  129. },
  130. // 清空表单
  131. clearForm() {
  132. this.newItem = {
  133. borrowItem: '',
  134. unit: '',
  135. price: '',
  136. quantity: '',
  137. applyAmount: 0
  138. }
  139. },
  140. // 取消添加
  141. cancelAdd() {
  142. this.clearForm()
  143. this.showAddPopup = false
  144. },
  145. getTotal() {
  146. return (Number(this.newItem.price) * Number(this.newItem.quantity)).toFixed(2)
  147. },
  148. deleteItem(item) {
  149. this.$modal.confirm('是否删除开支项目为'+item.borrowItem+'的项?').then(() => {
  150. delBorrowDetailByDetailId(item.borrowDetailId).then(res => {
  151. this.$message.success(res.msg)
  152. })
  153. })
  154. }
  155. },
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. .container {
  160. padding: 20rpx 30rpx;
  161. background-color: #f8f8f8;
  162. }
  163. /* 列表标题样式 */
  164. .list-header {
  165. display: flex;
  166. justify-content: space-between;
  167. padding: 20rpx 0;
  168. font-weight: bold;
  169. border-bottom: 1rpx solid #eee;
  170. }
  171. .list-box {
  172. margin-bottom: 20rpx;
  173. padding: 30rpx 10rpx;
  174. border-bottom: 1rpx solid #eee;
  175. background-color: #fff;
  176. border-radius: 12rpx;
  177. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  178. .indexs {
  179. font-size: 25rpx;
  180. height: 30rpx;
  181. position: relative;
  182. text {
  183. display: block;
  184. position: absolute;
  185. right: 10rpx;
  186. width: 32rpx;
  187. height: 32rpx;
  188. text-align: center;
  189. }
  190. }
  191. .box-button {
  192. display: flex;
  193. padding: 10rpx;
  194. }
  195. }
  196. /* 列表项样式 */
  197. .list-item {
  198. display: flex;
  199. justify-content: space-between;
  200. align-items: center;
  201. }
  202. .item-left {
  203. flex: 1;
  204. }
  205. .item-title {
  206. display: block;
  207. font-size: 32rpx;
  208. font-weight: bold;
  209. color: #333;
  210. margin-bottom: 15rpx;
  211. }
  212. .item-sub {
  213. font-size: 26rpx;
  214. color: #999;
  215. }
  216. .total-amount {
  217. font-size: 30rpx;
  218. color: #f1a532;
  219. font-weight: bold;
  220. padding-right: 30rpx;
  221. }
  222. .delete {
  223. font-size: 30rpx;
  224. color: #ff6a6c;
  225. font-weight: bold;
  226. }
  227. .edit {
  228. font-size: 30rpx;
  229. color: #3c9cff;
  230. font-weight: bold;
  231. padding-right: 20rpx;
  232. }
  233. /* 金额列对齐 */
  234. .amount {
  235. min-width: 100rpx;
  236. padding-right: 20rpx;
  237. }
  238. .item-right {
  239. min-width: 200rpx;
  240. text-align: right;
  241. }
  242. .add-popup {
  243. position: fixed;
  244. top: 0;
  245. left: 0;
  246. right: 0;
  247. bottom: 0;
  248. background-color: rgba(0, 0, 0, 0.5);
  249. display: flex;
  250. justify-content: center;
  251. align-items: center;
  252. z-index: 999;
  253. }
  254. .popup-content {
  255. background-color: white;
  256. width: 600rpx;
  257. padding: 40rpx;
  258. border-radius: 20rpx;
  259. }
  260. .popup-title {
  261. font-size: 36rpx;
  262. font-weight: bold;
  263. display: block;
  264. margin-bottom: 40rpx;
  265. }
  266. </style>