移动端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

247 wiersze
8.2 KiB

  1. <template>
  2. <div class="app-container">
  3. <van-nav-bar left-arrow fixed placeholder @click-left="goBack">
  4. <template #title>
  5. <p style="font-weight: bold;">{{ navBarTitle }}</p>
  6. </template>
  7. <template #right>
  8. <van-icon name="../../../static/images/icon/icon_flow.png" size="20" @click="goFlow"/>
  9. </template>
  10. </van-nav-bar>
  11. <van-form @submit="submitForm" @failed="getError" :show-error-message="false" scroll-to-error validate-first>
  12. <div class="main_box">
  13. <van-field v-model="form.cashAt" label="申请日期" placeholder="请选择申请日期"
  14. required :rules="[{ required: true }]"
  15. input-align="right" right-icon="arrow-down"
  16. readonly clickable @click="showCashAt = true" />
  17. <van-popup v-model="showCashAt" position="bottom">
  18. <van-datetime-picker
  19. :value="currentDate"
  20. type="date"
  21. title="请选择申请日期"
  22. :min-date="minDate"
  23. :max-date="maxDate"
  24. @confirm="onConfirmCashAt"
  25. @cancel="showCashAt = false"
  26. />
  27. </van-popup>
  28. <van-field v-model="form.cashAmount" label="申请金额(元)" placeholder="请输入申请金额(元)"
  29. required :rules="[{ required: true }]" input-align="right" type="number" />
  30. <van-field v-model="capitalExpenditureType" label="资金支出类别" placeholder="请选择资金支出类别"
  31. required :rules="[{ required: true }]"
  32. input-align="right" right-icon="arrow-down"
  33. readonly clickable @click="showType = true" />
  34. <van-popup v-model="showType" position="bottom">
  35. <van-picker
  36. show-toolbar
  37. :columns="capitalExpenditureTypeOptions"
  38. value-key="dictLabel"
  39. @confirm="onConfirmType"
  40. @cancel="showType = false"
  41. />
  42. </van-popup>
  43. <van-field v-model="form.cashRemarks" label="支款说明" placeholder="请输入支款说明"
  44. required :rules="[{ required: true }]" input-align="right" maxlength="200" />
  45. <van-field v-model="form.cashierNo" label="付款账号" placeholder="请输入付款账号"
  46. input-align="right" maxlength="50" />
  47. <van-field v-model="form.cashierName" label="付款单位" placeholder="请输入付款单位"
  48. input-align="right" maxlength="150" />
  49. <van-field v-model="form.payeeName" label="收款方名称" placeholder="请输入收款方名称"
  50. input-align="right" maxlength="150" />
  51. <van-field v-model="form.payeePhone" label="收款方电话" placeholder="请输入收款方电话"
  52. input-align="right" maxlength="20" />
  53. <van-field v-model="approvalTemplateName" label="审批流程" placeholder="请选择审批流程"
  54. required :rules="[{ required: true }]"
  55. input-align="right" right-icon="arrow-down"
  56. readonly clickable @click="showTemplate = true"
  57. />
  58. <van-popup v-model="showTemplate" position="bottom">
  59. <van-picker
  60. show-toolbar
  61. :columns="templateList"
  62. value-key="name"
  63. @confirm="onConfirmTemplate"
  64. @cancel="showTemplate = false"
  65. />
  66. </van-popup>
  67. </div>
  68. <div style="padding: 16px 0;">
  69. <van-row >
  70. <van-col span="24" align="center">
  71. <van-button type="info" native-type="submit" class="submitButton">保<i style="margin-right: 1em;"></i>存</van-button>
  72. </van-col>
  73. </van-row>
  74. </div>
  75. </van-form>
  76. </div>
  77. </template>
  78. <script>
  79. import { selectApprovalByTemplateId, listTemplate } from "@/api/onlineHome/bankAgriculture/paymentApproval";
  80. import { addCashExpense, updateCashExpense, getCashExpense } from "@/api/onlineHome/bankAgriculture/cashExpense";
  81. export default {
  82. name: "cashExpenseForm",
  83. data() {
  84. return {
  85. navBarTitle: '',
  86. showCashAt: false,
  87. minDate: new Date(1978, 0, 1),
  88. maxDate: new Date(2100, 11, 31),
  89. currentDate: new Date(),
  90. form: {},
  91. capitalExpenditureType: null,
  92. capitalExpenditureTypeOptions:[],
  93. showType: false,
  94. approvalTemplateName: null,
  95. showTemplate:false,
  96. templateList:[],
  97. };
  98. },
  99. created() {
  100. this.reset();
  101. this.getDicts("capital_expenditure_type").then((res) => {
  102. this.capitalExpenditureTypeOptions = res.data;
  103. });
  104. listTemplate({ type: '10' }).then(response => {
  105. this.templateList = response.rows;
  106. });
  107. if (this.$route.query.id) {
  108. this.navBarTitle = '修改资金审批申请';
  109. this.getDetail();
  110. } else {
  111. this.navBarTitle = '添加资金审批申请';
  112. }
  113. },
  114. methods: {
  115. goBack(){
  116. this.$router.push({path:'/yinnong/cashExpenseList'})
  117. },
  118. onConfirmCashAt(data) {
  119. this.form.cashAt = this.format(data, 'yyyy-MM-dd');
  120. this.showCashAt = false;
  121. },
  122. onConfirmType(value){
  123. this.form.capitalExpenditureType = value.dictValue;
  124. this.capitalExpenditureType = value.dictLabel;
  125. this.showType = false;
  126. },
  127. // 表单重置
  128. reset() {
  129. this.form = {
  130. id: null,
  131. bookId: null,
  132. deptId: null,
  133. bookName: null,
  134. cashAt: null,
  135. cashAmount: null,
  136. cashRemarks: null,
  137. capitalExpenditureType: null,
  138. cashierNo: null,
  139. cashierName: null,
  140. payeeName: null,
  141. payeePhone: null,
  142. approvalTemplateId: null,
  143. auditStatus: null,
  144. auditbatchNo: null,
  145. createBy: null,
  146. createTime: null,
  147. updateBy: null,
  148. updateTime: null
  149. };
  150. },
  151. getDetail(){
  152. getCashExpense(this.$route.query.id).then(response => {
  153. this.form = response.data;
  154. this.capitalExpenditureType = this.selectDictLabel(this.capitalExpenditureTypeOptions, response.data.capitalExpenditureType);
  155. const template = this.templateList.find(item => item.id === response.data.approvalTemplateId);
  156. this.approvalTemplateName = template.name;
  157. });
  158. },
  159. onConfirmTemplate(data) {
  160. selectApprovalByTemplateId(data.id).then(res => {
  161. this.showTemplate = false;
  162. if (res.approvalDetails.length > 0) {
  163. this.approvalTemplateName = data.name
  164. this.form.approvalTemplateId = data.id
  165. } else {
  166. this.approvalTemplateName = null;
  167. this.form.approvalTemplateId = null;
  168. this.$notify({type: 'danger', message: '此流程无节点,无法选择!'});
  169. }
  170. });
  171. },
  172. getError(e){
  173. this.$notify({ type: 'danger', message: e.errors[0].message });
  174. },
  175. submitForm() {
  176. if (this.form.id) {
  177. updateCashExpense(this.form).then(response => {
  178. if (response.code === 200) {
  179. this.$toast({
  180. icon: 'success',
  181. message: '保存成功',
  182. duration: '1000',
  183. onClose: () => {
  184. this.goBack();
  185. }
  186. });
  187. }
  188. });
  189. } else {
  190. addCashExpense(this.form).then(response => {
  191. if (response.code === 200) {
  192. this.$toast({
  193. icon: 'success',
  194. message: '保存成功',
  195. duration: "1000",
  196. onClose: () => {
  197. this.goBack();
  198. }
  199. });
  200. }
  201. });
  202. }
  203. },
  204. goFlow() {
  205. if (this.form.id) { // 修改时
  206. this.$router.push({path: '/yinnong/cashExpenseProcess', query: { id: this.form.id, templateId: this.form.approvalTemplateId }});
  207. } else { // 新增时
  208. if (this.form.approvalTemplateId) {
  209. this.$router.push({path: '/yinnong/cashExpenseProcess', query: { templateId: this.form.approvalTemplateId }});
  210. } else {
  211. this.$notify({type: 'danger', message: '无审批流程!'});
  212. }
  213. }
  214. },
  215. }
  216. }
  217. </script>
  218. <style scoped lang="scss">
  219. .app-container {
  220. padding: 2% 0;
  221. }
  222. .main_box {
  223. width: 96%;
  224. margin: 0 auto;
  225. border-radius: 6px;
  226. box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.16);
  227. overflow: hidden;
  228. background-color: #FFF;
  229. }
  230. .submitButton {
  231. width: 80%;
  232. margin: 0 auto;
  233. background-color: #1D6FE9;
  234. }
  235. </style>