Detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <div class="card-container">
  3. <el-form
  4. :model="addForm"
  5. v-loading="loading"
  6. ref="addForm"
  7. label-position="right"
  8. label-width="180px">
  9. <div class="card-content">
  10. <div class="section-title">Monthly Credit Limit:</div>
  11. <el-row :gutter="20">
  12. <el-col :xs="24" :md="12">
  13. <el-form-item
  14. label="Group:"
  15. prop="groupPk">
  16. <el-select
  17. class="add-text"
  18. v-model="addForm.groupPk"
  19. placeholder="Select with search"
  20. disabled>
  21. <el-option
  22. v-for="(item, index) in companyOptions"
  23. :key="index"
  24. :label="item.groupName"
  25. :value="item.groupPk"/>
  26. </el-select>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :xs="24" :md="12">
  30. <el-form-item
  31. label="Status:"
  32. prop="dataStatus">
  33. <el-select
  34. class="add-text"
  35. v-model="addForm.dataStatus"
  36. placeholder="Select"
  37. disabled>
  38. <el-option
  39. v-for="(item, index) in statusOptions"
  40. :key="index"
  41. :label="item.name"
  42. :value="item.value"/>
  43. </el-select>
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. <el-row :gutter="20">
  48. <el-col :xs="24" :md="12">
  49. <el-form-item
  50. label="Monthly Credit Limit:"
  51. prop="creditLimitAmount">
  52. <span class="item-unit">(S$)</span>
  53. <el-input
  54. class="add-text"
  55. v-model="addForm.creditLimitAmount"
  56. placeholder=""
  57. readonly/>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :xs="24" :md="12">
  61. <el-form-item
  62. label="Effective Start Date:"
  63. prop="effectiveStartDate">
  64. <el-date-picker
  65. class="add-text"
  66. v-model="addForm.effectiveStartDate"
  67. type="date"
  68. format="yyyy-MM-dd"
  69. value-format="yyyy-MM-dd"
  70. placeholder="Select date"
  71. disabled/>
  72. </el-form-item>
  73. </el-col>
  74. </el-row>
  75. <el-row :gutter="20">
  76. <el-col :xs="24" :md="12">
  77. <el-form-item
  78. label="Used Credit Limit:">
  79. <span class="item-unit">(S$)</span>
  80. <el-input
  81. class="add-text"
  82. v-model="addForm.usedCreditLimitAmount"
  83. placeholder=""
  84. maxlength="10"
  85. readonly/>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :xs="24" :md="12">
  89. <el-form-item
  90. label="Effective End Date:"
  91. prop="effectiveEndDate">
  92. <el-date-picker
  93. class="add-text"
  94. v-model="addForm.effectiveEndDate"
  95. type="date"
  96. format="yyyy-MM-dd"
  97. value-format="yyyy-MM-dd"
  98. placeholder="Select date"
  99. disabled/>
  100. </el-form-item>
  101. </el-col>
  102. </el-row>
  103. <el-row :gutter="20">
  104. <el-col :xs="24" :md="12">
  105. <el-form-item
  106. label="Remaining Credit Limit:">
  107. <span class="item-unit">(S$)</span>
  108. <el-input
  109. class="add-text"
  110. v-model="addForm.creditLimitRemainingAmount"
  111. placeholder=""
  112. readonly
  113. maxlength="10"/>
  114. </el-form-item>
  115. </el-col>
  116. <el-col :xs="24" :md="12">
  117. <el-form-item
  118. label="Deposit Received:"
  119. prop="depositReceivedAmount">
  120. <span class="item-unit">(S$)</span>
  121. <el-input
  122. class="add-text"
  123. v-model="addForm.depositReceivedAmount"
  124. placeholder=""
  125. readonly/>
  126. </el-form-item>
  127. </el-col>
  128. </el-row>
  129. <el-row :gutter="20">
  130. <el-col :xs="24" :md="12">
  131. <el-form-item
  132. label="Service Provider:"
  133. prop="providerPk">
  134. <el-select
  135. class="add-text"
  136. v-model="addForm.providerPk"
  137. placeholder="Select"
  138. disabled>
  139. <el-option
  140. v-for="(item, index) in providerOptions"
  141. :key="index"
  142. :label="item.providerName"
  143. :value="''+item.providerPk"/>
  144. </el-select>
  145. </el-form-item>
  146. </el-col>
  147. </el-row>
  148. </div>
  149. <div class="card-content flexcr">
  150. <div class="buttons">
  151. <el-button
  152. type="primary"
  153. class="cancel-button"
  154. @click="handleClickCancleButton">
  155. Back
  156. </el-button>
  157. </div>
  158. <div
  159. class="flex1"
  160. style="margin-left: 20px;"
  161. v-if="isEdit">
  162. <span
  163. class="add-text"
  164. :title='"CREATED BY " + addForm.createdBy + " ON " + addForm.createdOn'>
  165. LAST UPDATED BY {{addForm.updatedBy}} TIMESTAMP: {{addForm.updatedOn}}
  166. </span>
  167. </div>
  168. </div>
  169. </el-form>
  170. </div>
  171. </template>
  172. <script>
  173. import limit from '../../http/api/limit.js'
  174. import provider from '../../http/api/provider'
  175. import group from '@/http/api/group'
  176. export default {
  177. data() {
  178. return {
  179. loading: false,
  180. companyOptions: [],
  181. statusOptions: [],
  182. providerOptions: [],
  183. addForm: {
  184. groupPk: '',
  185. creditLimitAmount: '',
  186. depositReceivedAmount: '',
  187. effectiveStartDate: "",
  188. effectiveEndDate: "",
  189. dataStatus: "",
  190. providerPk: "",
  191. usedCreditLimitAmount: "0",
  192. creditLimitRemainingAmount: '0'
  193. },
  194. companyParams: {
  195. "pageSize": 20,
  196. "pageNo": 1,
  197. "pageVo": {
  198. "criteria": ""
  199. }
  200. },
  201. isEdit: false
  202. }
  203. },
  204. created() {
  205. this.loading = true;
  206. this.getCompanyList()
  207. if (this.$route.params.id) {
  208. this.isEdit = true;
  209. this.getLimitInfo()
  210. }
  211. },
  212. methods: {
  213. clearWords() {
  214. this.companyParams.pageVo.criteria = "";
  215. this.getCompanyList();
  216. },
  217. filterCompany(word) {
  218. this.companyParams.pageVo.criteria = word;
  219. this.getCompanyList();
  220. },
  221. getLimitInfo() {
  222. limit.viewCreditLimit(this.$route.params.id).then(res => {
  223. if (res.data) {
  224. this.addForm = res.data
  225. }
  226. }).catch(err => {
  227. this.loading = false;
  228. this.$message({
  229. message: err,
  230. type: 'error'
  231. })
  232. });
  233. },
  234. getCompanyList() {
  235. group.getGroupPages(this.companyParams).then(res => {
  236. if (res.data) {
  237. this.companyOptions = res.data
  238. }
  239. }).catch(err => {
  240. this.$message({
  241. message: err,
  242. type: 'error'
  243. })
  244. }).finally(() => {
  245. this.getLimitStatus();
  246. });
  247. },
  248. getLimitStatus() {
  249. limit.getLimitStatus().then(res => {
  250. if (res.data) {
  251. this.statusOptions = res.data
  252. }
  253. }).catch(err => {
  254. this.$message({
  255. message: err,
  256. type: 'error'
  257. })
  258. }).finally(() => {
  259. this.getAllProvider()
  260. });
  261. },
  262. getAllProvider() {
  263. provider.getAllServiceProvider().then(res => {
  264. if (res.data && res.data.length > 0) {
  265. this.providerOptions = res.data
  266. if (!this.addForm.providerPk)
  267. this.addForm.providerPk = res.data[0].providerPk + ""
  268. }
  269. }).finally(() => {
  270. this.loading = false;
  271. });
  272. },
  273. handleClickCancleButton() {
  274. this.$nextTick(() => {
  275. this.$router.push({
  276. path: "/partnership-management/monthly-credit-management"
  277. })
  278. })
  279. },
  280. handleClickSaveButton() {
  281. this.$refs['addForm'].validate(result => {
  282. if (result) {
  283. this.isEdit ? this.updateLimites() : this.addLimites();
  284. }
  285. })
  286. },
  287. addLimites() {
  288. this.loading = true;
  289. limit.addCreditLimit(this.addForm).then(res => {
  290. this.loading = false;
  291. this.$message({
  292. message: 'Add credit limit successfully',
  293. type: 'success'
  294. })
  295. this.handleClickCancleButton();
  296. }).catch(err => {
  297. this.loading = false;
  298. this.$message({
  299. message: err,
  300. type: 'error'
  301. })
  302. });
  303. },
  304. updateLimites() {
  305. this.loading = true;
  306. limit.updateCreditLimit(this.addForm).then(res => {
  307. this.loading = false;
  308. this.$message({
  309. message: 'Update credit limit successfully',
  310. type: 'success'
  311. })
  312. this.handleClickCancleButton();
  313. }).catch(err => {
  314. this.loading = false;
  315. this.$message({
  316. message: err,
  317. type: 'error'
  318. })
  319. });
  320. }
  321. }
  322. }
  323. </script>
  324. <style scoped="scoped" lang='scss'>
  325. @import '../../styles/variables.scss';
  326. .card-container {
  327. width: 100%;
  328. padding: 20px 60px;
  329. min-height: $mainAppMinHeight;
  330. background-color: #F0F5FC;
  331. }
  332. .card-content {
  333. margin: 0 8px 16px;
  334. padding: 15px 50px;
  335. border-radius: 6px;
  336. background-color: white;
  337. }
  338. .section-title {
  339. color: #333;
  340. margin-top: 20px;
  341. margin-bottom: 30px;
  342. font-size: 15px;
  343. user-select: none;
  344. line-height: 24px;
  345. font-weight: 700;
  346. font-family: sans-serif;
  347. text-transform: uppercase;
  348. }
  349. .add-text {
  350. width: 100%;
  351. font-size: 14px;
  352. max-width: 300px;
  353. }
  354. .add-text ::v-deep .el-textarea__inner {
  355. font-family: sans-serif;
  356. }
  357. .hr {
  358. height: 2px;
  359. margin: 10px -40px;
  360. background-color: #F0F5FC;
  361. }
  362. .hr-full {
  363. height: 2px;
  364. margin: 20px -80px;
  365. background-color: #F0F5FC;
  366. }
  367. .rate-list-view {
  368. display: flex;
  369. align-items: center;
  370. }
  371. .rate-text {
  372. max-width: 150px;
  373. padding-right: 14px;
  374. }
  375. .list-item-icon {
  376. width: 30px;
  377. height: 30px;
  378. cursor: pointer;
  379. margin: 0 10px 22px;
  380. }
  381. .buttons {
  382. padding-top: 15px;
  383. padding-bottom: 15px;
  384. }
  385. @media screen and (max-width: 500px) {
  386. .card-container {
  387. padding: 0px;
  388. }
  389. .card-content {
  390. padding: 15px 30px;
  391. }
  392. }
  393. .item-unit {
  394. top: 12px;
  395. left: -40px;
  396. font-size: 12px;
  397. user-select: none;
  398. position: absolute;
  399. }
  400. </style>