newAdd.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <el-form :model="formData" :rules="formRules" label-width="100px" ref="formRu">
  3. <el-form-item label="所属社区" prop="communityId">
  4. <el-select v-model="formData.communityId" placeholder="请选择社区">
  5. <el-option v-for="(item, index) in communityArr" :key="index" :label="item.communityName" :value="item.id"></el-option>
  6. </el-select>
  7. </el-form-item>
  8. <el-form-item label="费用类型" prop="chargeType">
  9. <el-select v-model="formData.chargeType" @change="chargeTypeToggle">
  10. <el-option label="物业费" :value="1"></el-option>
  11. <el-option label="水费" :value="2"></el-option>
  12. <el-option label="电费" :value="3"></el-option>
  13. <el-option label="车位费" :value="4"></el-option>
  14. <el-option label="卫生费" :value="6"></el-option>
  15. <el-option label="其他费用" :value="7"></el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="费用名称" prop="chargeName">
  19. <el-input v-model="formData.chargeName" placeholder="请输入费用名称"></el-input>
  20. </el-form-item>
  21. <el-form-item label="计费方式" prop="chargeMode">
  22. <el-select v-model="formData.chargeMode">
  23. <template v-if="formData.chargeType == 1">
  24. <el-option label="固定收费" :value="1"></el-option>
  25. <el-option label="价格*面积收费" :value="2"></el-option>
  26. </template>
  27. <template v-else-if="formData.chargeType == 2 || formData.chargeType == 3">
  28. <el-option label="单价*用量" :value="4"></el-option>
  29. </template>
  30. <template v-else>
  31. <el-option label="固定收费" :value="1"></el-option>
  32. </template>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item :label="labelActive" prop="chargePrice">
  36. <el-input v-model="formData.chargePrice" placeholder="请输入费用名称"></el-input>
  37. </el-form-item>
  38. <!-- 计费周期除水电费 -->
  39. <el-form-item label="计费周期" v-if="formData.chargeType !== 2 && formData.chargeType !== 3">
  40. <div class="form-item-flex">
  41. <el-select v-model="formData.chargeCycle" class="select">
  42. <el-option :label="item" v-for="item in 12" :value="item" :key="item"></el-option>
  43. </el-select>
  44. <div class="widthFlex">个月</div>
  45. </div>
  46. </el-form-item>
  47. <!-- 物业费收取滞纳金 -->
  48. <el-form-item label="收滞纳金" v-if="formData.chargeType === 1">
  49. <div class="form-item-flex">
  50. <el-input
  51. class="input-number"
  52. v-model="formData.lateFee"
  53. controls-position="right"
  54. oninput="value=value.replace(/[^0-9.]/g,'')"
  55. >
  56. <i slot="suffix" style="font-style: normal; margin-right: 70px"
  57. >‰
  58. <div class="input-button">
  59. <span
  60. class="button down"
  61. @click="formData.lateFee <= 0 ? null : lateAdd('-')"
  62. :class="formData.lateFee <= 0 ? 'no-drop' : ''"
  63. ><i class="el-icon-arrow-down"></i
  64. ></span>
  65. <span
  66. class="button up"
  67. :class="formData.lateFee >= 100 ? 'no-drop' : ''"
  68. @click="formData.lateFee >= 100 ? null : lateAdd('+')"
  69. ><i class="el-icon-arrow-up"></i
  70. ></span>
  71. </div>
  72. </i>
  73. </el-input>
  74. <el-tooltip class="item" effect="light" placement="right">
  75. <div slot="content" v-html="lateFeeMsg"></div>
  76. <img src="@/assets/img/menuicon/icon_tishi_zhengchang.png" alt="" />
  77. </el-tooltip>
  78. <div>欠费时间(>)</div>
  79. <el-input
  80. class="input"
  81. oninput="value=value.replace(/[^0-9.]/g,'')"
  82. v-model="formData.arrearsDays"
  83. placeholder="请输入天数"
  84. ></el-input>
  85. </div>
  86. </el-form-item>
  87. <!-- 生成规则除水电费 -->
  88. <el-form-item label="生成规则" v-if="formData.chargeType !== 2 && formData.chargeType !== 3">
  89. <el-select v-model="formData.generationRules">
  90. <el-option label="预生成账单" :value="1"></el-option>
  91. <el-option label="后生成账单" :value="2"></el-option>
  92. </el-select>
  93. </el-form-item>
  94. <el-form-item label="备注" prop="desc">
  95. <el-input
  96. type="textarea"
  97. placeholder="请输入备注"
  98. v-model="formData.remark"
  99. :rows="3"
  100. maxlength="100"
  101. show-word-limit
  102. resize="none"
  103. ></el-input>
  104. </el-form-item>
  105. </el-form>
  106. </template>
  107. <script >
  108. export default {
  109. props: ['params'],
  110. data() {
  111. return {
  112. formData: {
  113. communityId: '',
  114. arrearsDays: '',
  115. chargeType: 1,
  116. chargeName: '',
  117. chargeMode: '',
  118. chargePrice: '',
  119. chargeCycle: 1,
  120. chargeCycleUnit: 1,
  121. generationRules: '',
  122. lateFee: 1,
  123. remark: ''
  124. },
  125. lateFeeMsg: '滞纳金计算规则:</br>月费用*逾期天数*滞纳金标准',
  126. formRules: {
  127. chargeName: [this.$valid.inputRequired('费用名称')],
  128. chargePrice: [this.$valid.inputRequired('价格')],
  129. chargeMode: [this.$valid.selectRequired('计费方式')],
  130. chargeType: [this.$valid.selectRequired('费用类型')],
  131. communityId: [this.$valid.selectRequired('社区')]
  132. }
  133. };
  134. },
  135. computed: {
  136. communityArr() {
  137. return this.$store.getters['getAreaSelect'];
  138. },
  139. labelActive() {
  140. let text = '价格(元/月)';
  141. switch (this.formData.chargeType) {
  142. case 2:
  143. text = '价格(元/吨)';
  144. break;
  145. case 3:
  146. text = '价格(元/度)';
  147. break;
  148. }
  149. return text;
  150. }
  151. },
  152. methods: {
  153. lateAdd(fu) {
  154. if (this.formData.lateFee == null || this.formData.lateFee == undefined) {
  155. this.formData.lateFee = 1;
  156. }
  157. let newx = Number(this.formData.lateFee);
  158. if (newx >= 0) {
  159. if (fu == '-') {
  160. this.formData.lateFee = newx - 1;
  161. } else if (fu == '+') {
  162. this.formData.lateFee = newx + 1;
  163. }
  164. }
  165. },
  166. submit() {
  167. this.$refs['formRu'].validate((valid) => {
  168. if (valid) {
  169. let formData = this.installFromData();
  170. var loading = this.$loading();
  171. let url = '/sc-charge/scChargeStrategy/add';
  172. if (this.params.todo === 'edit') {
  173. formData.id = this.params.data.id;
  174. url = '/sc-charge/scChargeStrategy/update';
  175. }
  176. this.$http
  177. .post(url, formData)
  178. .then(({ status, msg }) => {
  179. if (status == 0) {
  180. this.$message.success(msg);
  181. this.params.callback();
  182. this.$emit('close');
  183. } else {
  184. this.$message.error(msg);
  185. }
  186. loading.close();
  187. })
  188. .catch(() => {
  189. loading.close();
  190. });
  191. } else {
  192. return false;
  193. }
  194. });
  195. },
  196. installFromData() {
  197. let installData = {
  198. communityId: this.formData.communityId,
  199. chargeType: this.formData.chargeType,
  200. chargeName: this.formData.chargeName,
  201. chargeMode: this.formData.chargeMode,
  202. remark: this.formData.remark,
  203. chargePrice: this.formData.chargePrice
  204. };
  205. if (this.formData.chargeType === 1) {
  206. installData.lateFee = this.formData.lateFee;
  207. installData.arrearsDays = this.formData.arrearsDays;
  208. }
  209. if (this.formData.chargeType !== 2 && this.formData.chargeType !== 3) {
  210. installData.generationRules = this.formData.generationRules;
  211. installData.chargeCycle = this.formData.chargeCycle;
  212. }
  213. return installData;
  214. },
  215. chargeTypeToggle() {
  216. this.$refs['formRu'].clearValidate('chargeMode');
  217. this.formData.chargeMode = '';
  218. }
  219. },
  220. created() {
  221. if (this.params.todo == 'edit') {
  222. let paramsData = JSON.parse(JSON.stringify(this.params.data));
  223. if (paramsData.chargeCycle == null) {
  224. paramsData.chargeCycle = 1;
  225. }
  226. Object.assign(this.formData, paramsData);
  227. }
  228. }
  229. };
  230. </script>
  231. <style lang="scss" scoped>
  232. .just {
  233. justify-content: space-between;
  234. }
  235. .form-item-flex {
  236. display: flex;
  237. .input {
  238. width: 110px;
  239. margin: 0 15px 0 12px;
  240. }
  241. .input-number {
  242. width: 110px;
  243. /deep/ .el-input__suffix {
  244. height: 33px ;
  245. }
  246. /deep/ .el-input--suffix .el-input__inner {
  247. padding-right: 50px;
  248. }
  249. .input-button {
  250. line-height: 15px;
  251. .button {
  252. cursor: pointer;
  253. &.no-drop {
  254. cursor: no-drop;
  255. background: #dcdfe6;
  256. }
  257. }
  258. .up {
  259. position: absolute;
  260. top: 2px;
  261. height: 16px;
  262. width: 25px;
  263. right: -4px;
  264. border-radius: 0px 4px 0 0;
  265. background: white;
  266. border-bottom: 1px solid #dcdfe6;
  267. border-left: 1px solid #dcdfe6;
  268. }
  269. .down {
  270. position: absolute;
  271. bottom: 1px;
  272. height: 16px;
  273. width: 25px;
  274. right: -4px;
  275. background: white;
  276. border-radius: 0 0 4px 0;
  277. border-top: 1px solid #dcdfe6;
  278. border-left: 1px solid #dcdfe6;
  279. }
  280. }
  281. }
  282. .input100 {
  283. width: 100px;
  284. }
  285. .select {
  286. width: 360px !important;
  287. }
  288. .el-tooltip {
  289. margin: 10px 10px 0 16px;
  290. width: 16px;
  291. height: 16px;
  292. }
  293. .widthFlex {
  294. flex: 1;
  295. text-align: right;
  296. white-space: nowrap;
  297. }
  298. .sunm {
  299. width: 15px;
  300. text-align: center;
  301. cursor: pointer;
  302. }
  303. }
  304. </style>