add.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <div>
  3. <div class="steps">
  4. <div class="steps-item active">
  5. <div class="circularText"><span>1</span></div>
  6. <div>基本信息</div>
  7. <div class="steps-item-line" :class="showIndex > 0 ? 'active' : ''"></div>
  8. </div>
  9. <div class="steps-item" :class="showIndex > 0 ? 'active' : ''">
  10. <div class="circularText"><span>2</span></div>
  11. <div>金额条款</div>
  12. <div class="steps-item-line" :class="showIndex > 1 ? 'active' : ''"></div>
  13. </div>
  14. <div class="steps-item" :class="showIndex > 1 ? 'active' : ''">
  15. <div class="circularText"><span>3</span></div>
  16. <div>收款计划</div>
  17. </div>
  18. </div>
  19. <first-step v-show="showIndex == 0" ref="firststepRef"></first-step>
  20. <step-two ref="steptwoRef" v-show="showIndex == 1"></step-two>
  21. <last-step v-show="showIndex == 2"></last-step>
  22. </div>
  23. </template>
  24. <script >
  25. import firstStep from './firstStep.vue';
  26. import stepTwo from './stepTwo.vue';
  27. import lastStep from './lastStep.vue';
  28. import { Promise } from 'q';
  29. export default {
  30. props: ['params'],
  31. components: {
  32. firstStep,
  33. stepTwo,
  34. lastStep
  35. },
  36. data() {
  37. return {
  38. showIndex: 0,
  39. formData: {
  40. contractNo: '',
  41. filePath: '',
  42. contractType: 0,
  43. customerType: null,
  44. communityId: '',
  45. signTime: '',
  46. startTime: '',
  47. endTime: '',
  48. customerName: '',
  49. customerPhone: '',
  50. customerAddress: '',
  51. contractHouseDtoList: []
  52. },
  53. //租赁规则
  54. rules: {
  55. ruleId: '',
  56. enable: 1,
  57. earnestMoney: '',
  58. freeTime: ''
  59. },
  60. contractPlanDtos: [],
  61. chargeCycle: '',
  62. times: [],
  63. timesTwo: [],
  64. pictureArr: [],
  65. relationTable: {},
  66. formRules: {
  67. customerName: [this.$valid.inputRequired('客户名称')],
  68. customerPhone: [this.$valid.inputRequired('客户手机')],
  69. customerAddress: [this.$valid.inputRequired('联系地址')],
  70. communityId: [this.$valid.selectRequired('社区')],
  71. signTime: [this.$valid.selectRequired('签订时间')],
  72. startTime: this.$valid.custome({
  73. validator(rule, value, cb) {
  74. const rl = rule;
  75. if (!value) {
  76. rl.message = '请选择合同时间';
  77. cb(new Error());
  78. } else {
  79. cb();
  80. }
  81. }
  82. })
  83. },
  84. //多选
  85. idsObj: [],
  86. //社区
  87. communityArr: [],
  88. //社区树
  89. communityTree: [],
  90. //楼栋树
  91. communityTreeArr: [],
  92. //楼栋ids
  93. communityTreeIds: [],
  94. tableArr: [],
  95. defaultProps: {
  96. multiple: true,
  97. emitPath: false,
  98. value: 'value', // 唯一标识
  99. label: 'name', // 标签显示
  100. children: 'children' // 子级
  101. },
  102. loadings: false
  103. };
  104. },
  105. watch: {
  106. pictureArr(val) {
  107. this.formData.filePath = val.join();
  108. }
  109. },
  110. methods: {
  111. submit() {
  112. let nameArr = [];
  113. this.tableArr.map((item) => {
  114. nameArr.push(`${item.communityName}-${item.buildingName}-${!!item.unitName ? item.unitName + '-' : ''}${item.roomNumber}`);
  115. });
  116. let installData = this.formData;
  117. let installObj = JSON.parse(JSON.stringify(this.idsObj));
  118. installObj.map((item, index) => {
  119. delete item.thisArr;
  120. delete item.timesTwo;
  121. delete item.increasingYear;
  122. delete item.increasingPercentage;
  123. });
  124. installData.houseName = nameArr.join(',');
  125. installData.contractHouseDtoList = installObj;
  126. var loading = this.$loading();
  127. this.$http
  128. .post(`/sc-community/contract/${this.params.todo == 'add' ? 'add' : 'edit'}`, installData)
  129. .then(({ status, msg }) => {
  130. if (status == 0) {
  131. this.$message.success(msg);
  132. this.params.callback();
  133. this.$emit('close');
  134. } else {
  135. this.$message.error(msg);
  136. }
  137. loading.close();
  138. })
  139. .catch(() => {
  140. loading.close();
  141. });
  142. },
  143. findDetali(id) {
  144. this.$http
  145. .get('/sc-community/enterprise/find/' + id)
  146. .then(({ data, status, msg }) => {
  147. if (0 === status) {
  148. if (data !== null) {
  149. this.pictureArr = !!data.businessLicense ? data.businessLicense.split(',') : [];
  150. Object.assign(this.formData, data);
  151. }
  152. } else {
  153. this.$message.error(msg);
  154. }
  155. })
  156. .catch(() => {});
  157. },
  158. effectiveDateToggle(e) {
  159. this.formData.startTime = `${!!e ? e[0] : ''}`;
  160. this.formData.endTime = `${!!e ? e[1] : ''}`;
  161. },
  162. relation() {
  163. new Promise((resolve) => {
  164. this.$store.dispatch('addPopup', {
  165. url: '/businessManagement/enterpriseManagement/index.vue',
  166. width: '850px',
  167. height: '400px',
  168. props: {
  169. callback: resolve
  170. },
  171. hideStar: true,
  172. title: '关联企业'
  173. });
  174. }).then((res) => {
  175. this.relationTable = res;
  176. });
  177. },
  178. modePop(id) {
  179. let indexs = null;
  180. this.$store.getters['getPopups'].map((item, index) => {
  181. if (item.id == id) {
  182. indexs = index;
  183. }
  184. });
  185. return indexs;
  186. },
  187. nextStep(id) {
  188. let thisPopArr = this.$store.getters['getPopups'];
  189. let thisPop = thisPopArr[this.modePop(id)];
  190. // 0 取消 下一步 ,1 取消 上一步 下一步 ,2 确认 取消 上一步
  191. if (thisPop.showIndex == 0) {
  192. this.$refs.firststepRef.$refs.form.validate((valid) => {
  193. if (valid) {
  194. thisPop.showIndex++;
  195. thisPop.nextStepButton = true;
  196. thisPop.previousStepButton = true;
  197. thisPop.showConfirmButton = true;
  198. this.showIndex = thisPop.showIndex;
  199. }
  200. });
  201. } else if (thisPop.showIndex == 1) {
  202. new Promise((resolve) => {
  203. this.$refs.steptwoRef.chanIndexSumit(resolve);
  204. }).then(() => {
  205. thisPop.showIndex++;
  206. this.$refs.steptwoRef.getList();
  207. // 第二流程 下一步
  208. thisPop.nextStepButton = false;
  209. thisPop.showConfirmButton = false;
  210. thisPop.previousStepButton = true;
  211. this.showIndex = thisPop.showIndex;
  212. });
  213. }
  214. },
  215. previousStep(id) {
  216. let thisPopArr = this.$store.getters['getPopups'];
  217. let thisPop = thisPopArr[this.modePop(id)];
  218. thisPop.showIndex--;
  219. if (thisPop.showIndex == 0) {
  220. thisPop.nextStepButton = true;
  221. thisPop.previousStepButton = false;
  222. thisPop.showConfirmButton = true;
  223. } else if (thisPop.showIndex == 1) {
  224. thisPop.nextStepButton = true;
  225. thisPop.previousStepButton = true;
  226. thisPop.showConfirmButton = true;
  227. }
  228. this.showIndex = thisPop.showIndex;
  229. },
  230. randomPassword() {
  231. let sun = 15;
  232. let randomNumber = [];
  233. for (let numb = 0; numb < sun; numb++) {
  234. randomNumber.push(parseInt(Math.ceil(Math.random() * sun)));
  235. }
  236. this.formData.contractNo = randomNumber.toString().replace(/,/g, '');
  237. }
  238. },
  239. created() {
  240. this.randomPassword();
  241. const { todo, data, communityArr, communityTree } = this.params;
  242. this.communityArr = communityArr;
  243. this.communityTree = communityTree;
  244. if (todo !== 'add') {
  245. this.findDetali(data.id);
  246. }
  247. }
  248. };
  249. </script>
  250. <style lang="scss" scoped>
  251. .formContent-item_title {
  252. clear: both;
  253. }
  254. .timeWidth {
  255. width: 100%;
  256. }
  257. .mrbt20 {
  258. margin-bottom: 20px;
  259. }
  260. /deep/ .el-date-editor .el-range-separator {
  261. padding: 0;
  262. }
  263. /deep/ .el-form-item__label,
  264. /deep/ .el-input__inner {
  265. font-size: 12px;
  266. }
  267. .steps {
  268. display: flex;
  269. justify-content: space-between;
  270. color: #dbdbdb;
  271. .steps-item {
  272. display: flex;
  273. line-height: 36px;
  274. position: relative;
  275. margin-bottom: 24px;
  276. .circularText {
  277. height: 36px;
  278. width: 36px;
  279. display: inline-block;
  280. line-height: 36px;
  281. border-radius: 50%;
  282. position: relative;
  283. text-align: center;
  284. margin-right: 10px;
  285. color: #dbdbdb;
  286. span {
  287. position: absolute;
  288. top: 50%;
  289. left: 50%;
  290. transform: translate(-50%, -50%);
  291. display: inline-block;
  292. background: #f8fcff;
  293. height: 28px;
  294. width: 28px;
  295. line-height: 28px;
  296. border-radius: 50%;
  297. }
  298. }
  299. .steps-item-line {
  300. position: absolute;
  301. left: 130px;
  302. top: 50%;
  303. width: 200px;
  304. height: 2px;
  305. background: #f8fcff;
  306. border-radius: 2px;
  307. &.active {
  308. background: #0eaeff;
  309. }
  310. }
  311. &.active {
  312. color: #424656;
  313. .circularText {
  314. background: #b5e6ff;
  315. color: white;
  316. span {
  317. background: #0eaeff;
  318. }
  319. }
  320. }
  321. }
  322. }
  323. </style>