apply.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div class="quota-apply-container">
  3. <div class="page-header">
  4. <el-button type="primary" link @click="handleBack"
  5. ><el-icon><ArrowLeft /></el-icon>返回</el-button
  6. >
  7. <span class="page-title">额度申请</span>
  8. </div>
  9. <el-form ref="formRef" :model="formData" :rules="rules" label-position="top" class="apply-form">
  10. <div class="form-row">
  11. <el-form-item label="月度采购金额" prop="monthPurchase">
  12. <el-input v-model="formData.monthPurchase" placeholder="请输入">
  13. <template #suffix>元</template>
  14. </el-input>
  15. </el-form-item>
  16. <el-form-item label="年度采购金额" prop="yearPurchase">
  17. <el-input v-model="formData.yearPurchase" placeholder="请输入">
  18. <template #suffix>元</template>
  19. </el-input>
  20. </el-form-item>
  21. </div>
  22. <div class="form-row">
  23. <el-form-item label="申请信用金额" prop="applyAmount">
  24. <el-input v-model="formData.applyAmount" placeholder="请输入">
  25. <template #suffix>元</template>
  26. </el-input>
  27. </el-form-item>
  28. <el-form-item label="账期时间" prop="amountPeriod">
  29. <el-select v-model="formData.amountPeriod" placeholder="请选择" style="width: 100%">
  30. <el-option label="30天" value="30" />
  31. <el-option label="60天" value="60" />
  32. <el-option label="90天" value="90" />
  33. </el-select>
  34. </el-form-item>
  35. </div>
  36. <el-form-item label="主要办公采购类目" prop="mainPurchase">
  37. <div class="mainPurchase-tags">
  38. <div
  39. v-for="item in categoryList"
  40. :key="item.value"
  41. :class="['tag-item', { active: formData.mainPurchase === item.value }]"
  42. @click="formData.mainPurchase = item.value"
  43. >
  44. {{ item.label }}
  45. </div>
  46. </div>
  47. </el-form-item>
  48. <el-form-item label="其他采购类目" prop="otherPurchase">
  49. <el-input v-model="formData.otherPurchase" type="textarea" :rows="2" placeholder="请输入" maxlength="50" show-word-limit />
  50. </el-form-item>
  51. <el-form-item label="上传合作协议" prop="cooperationImage">
  52. <el-upload action="#" :auto-upload="false" :limit="1" list-type="picture-card">
  53. <div class="upload-content">
  54. <el-icon><Plus /></el-icon>
  55. <span>上传</span>
  56. </div>
  57. </el-upload>
  58. </el-form-item>
  59. <div class="form-actions">
  60. <el-button type="danger" @click="handleSave">保存</el-button>
  61. <el-button @click="handleBack">取消</el-button>
  62. </div>
  63. </el-form>
  64. </div>
  65. </template>
  66. <script setup lang="ts">
  67. import { ref, reactive } from 'vue';
  68. import { useRouter } from 'vue-router';
  69. import { ArrowLeft, Plus } from '@element-plus/icons-vue';
  70. import { ElMessage } from 'element-plus';
  71. import { addCreditApply } from '@/api/pc/cost/creditApply';
  72. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  73. const { purchase_item } = toRefs<any>(proxy?.useDict('purchase_item'));
  74. const router = useRouter();
  75. const formRef = ref();
  76. const formData = reactive({
  77. monthPurchase: '',
  78. yearPurchase: '',
  79. applyAmount: '',
  80. amountPeriod: '',
  81. mainPurchase: '0',
  82. otherPurchase: '',
  83. cooperationImage: ''
  84. });
  85. const categoryList = computed(() => purchase_item.value || []);
  86. const rules = {
  87. monthPurchase: [{ required: true, message: '请输入月度采购金额', trigger: 'blur' }],
  88. applyAmount: [{ required: true, message: '请输入申请信用金额', trigger: 'blur' }]
  89. };
  90. const handleBack = () => {
  91. router.back();
  92. };
  93. const handleSave = async () => {
  94. const valid = await formRef.value?.validate();
  95. if (!valid) return;
  96. try {
  97. await addCreditApply(formData);
  98. ElMessage.success('保存成功');
  99. handleBack();
  100. } catch (error) {
  101. ElMessage.error('保存失败');
  102. }
  103. };
  104. </script>
  105. <style scoped lang="scss">
  106. .quota-apply-container {
  107. padding: 20px;
  108. background: #fff;
  109. min-height: 100%;
  110. flex: 1;
  111. }
  112. .page-header {
  113. display: flex;
  114. align-items: center;
  115. gap: 10px;
  116. margin-bottom: 25px;
  117. .page-title {
  118. font-size: 16px;
  119. font-weight: bold;
  120. color: #333;
  121. }
  122. }
  123. .apply-form {
  124. max-width: 900px;
  125. .form-row {
  126. display: grid;
  127. grid-template-columns: 1fr 1fr;
  128. gap: 20px 40px;
  129. }
  130. :deep(.el-form-item__label) {
  131. font-size: 14px;
  132. color: #333;
  133. padding-bottom: 8px;
  134. }
  135. :deep(.el-input__wrapper),
  136. :deep(.el-select__wrapper),
  137. :deep(.el-textarea__inner) {
  138. background: #f5f5f5;
  139. box-shadow: none;
  140. }
  141. }
  142. .mainPurchase-tags {
  143. display: flex;
  144. flex-wrap: wrap;
  145. gap: 10px;
  146. .tag-item {
  147. padding: 6px 16px;
  148. border-radius: 4px;
  149. cursor: pointer;
  150. font-size: 13px;
  151. color: #666;
  152. background: #f5f5f5;
  153. transition: all 0.2s;
  154. &:hover {
  155. color: #e60012;
  156. }
  157. &.active {
  158. background: #e60012;
  159. color: #fff;
  160. }
  161. }
  162. }
  163. .upload-content {
  164. display: flex;
  165. flex-direction: column;
  166. align-items: center;
  167. justify-content: center;
  168. color: #999;
  169. font-size: 12px;
  170. .el-icon {
  171. font-size: 20px;
  172. margin-bottom: 5px;
  173. }
  174. }
  175. .form-actions {
  176. margin-top: 30px;
  177. display: flex;
  178. gap: 15px;
  179. }
  180. </style>