newAdd.vue 11 KB

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