index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div>
  3. <BaseDialog
  4. width="600px"
  5. :isShow.sync="isShow"
  6. title="添加"
  7. @submit="submitForm"
  8. @close="close"
  9. confirmName="下一步"
  10. >
  11. <el-form
  12. :model="formData"
  13. :rules="rules"
  14. ref="formData"
  15. label-width="100px"
  16. class="demo-ruleForm"
  17. ><el-form-item label="标题:" prop="title">
  18. <el-input
  19. clearable
  20. v-model="formData.title"
  21. placeholder="请输入标题"
  22. ></el-input>
  23. </el-form-item>
  24. <el-form-item label="成本分类:" prop="costCatId">
  25. <el-select v-model="formData.costCatId" placeholder="请选择成本分类">
  26. <el-option
  27. v-for="(item, index) in topinstcategoryList"
  28. :key="index"
  29. :label="item.categoryName"
  30. :value="item.costCatId"
  31. @click.native="formData.costCatName = item.categoryName"
  32. ></el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="供应商:" prop="instId">
  36. <el-select v-model="formData.instId" placeholder="请选择供应商">
  37. <el-option
  38. v-for="(item, index) in topinstitutionList"
  39. :key="index"
  40. :label="item.instName"
  41. :value="item.instId"
  42. @click.native="formData.instName = item.instName"
  43. >
  44. </el-option>
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item label="教育类型:" prop="educationTypeId">
  48. <el-select
  49. v-model="formData.educationTypeId"
  50. placeholder="请选择教育类型"
  51. >
  52. <el-option
  53. v-for="(item, index) in eduList"
  54. :key="index"
  55. :label="item.educationName"
  56. :value="item.id"
  57. @click.native="formData.educationName = item.educationName"
  58. >
  59. </el-option>
  60. </el-select>
  61. </el-form-item>
  62. <el-form-item label="培训项目:" prop="businessId">
  63. <el-select v-model="formData.businessId" placeholder="请选择培训项目">
  64. <el-option
  65. v-for="(item, index) in businessList(formData.educationTypeId)"
  66. :key="index"
  67. :label="item.businessName + item.projectName"
  68. :value="item.businessId"
  69. @click.native="changeFormDataBusiness(item)"
  70. >
  71. </el-option>
  72. </el-select> </el-form-item
  73. ><el-form-item label="备注:" prop="remark">
  74. <el-input
  75. type="textarea"
  76. clearable
  77. v-model="formData.remark"
  78. placeholder="请输入备注"
  79. ></el-input> </el-form-item
  80. ><el-form-item label="收款信息:" prop="bankName">
  81. <el-input
  82. disabled
  83. clearable
  84. v-model="formData.bankName"
  85. placeholder="开户名"
  86. ></el-input> </el-form-item
  87. ><el-form-item label="" prop="bank">
  88. <el-input
  89. disabled
  90. clearable
  91. v-model="formData.bank"
  92. placeholder="开户行"
  93. ></el-input> </el-form-item
  94. ><el-form-item label="" prop="bankAccount">
  95. <el-input
  96. disabled
  97. clearable
  98. v-model="formData.bankAccount"
  99. placeholder="收款账号"
  100. ></el-input>
  101. </el-form-item>
  102. </el-form>
  103. </BaseDialog>
  104. </div>
  105. </template>
  106. <script>
  107. import { mapGetters } from "vuex";
  108. export default {
  109. name: "",
  110. props: {
  111. dialogVisible: {
  112. type: Boolean,
  113. default: false,
  114. },
  115. activeData: {
  116. type: Object,
  117. default: () => {
  118. return {};
  119. },
  120. },
  121. },
  122. data() {
  123. return {
  124. formData: {
  125. title: "",
  126. costCatId: "",
  127. instId: "",
  128. educationTypeId: "",
  129. businessId: "",
  130. remark: "",
  131. },
  132. rules: {
  133. title: [{ required: true, message: "请输入标题", trigger: "blur" }],
  134. costCatId: [
  135. { required: true, message: "请选择成本分类", trigger: "change" },
  136. ],
  137. instId: [
  138. { required: true, message: "请选择供应商", trigger: "change" },
  139. ],
  140. educationTypeId: [
  141. { required: true, message: "请选择教育类型", trigger: "change" },
  142. ],
  143. businessId: [
  144. { required: true, message: "请选择培训项目", trigger: "change" },
  145. ],
  146. remark: [{ required: false, message: "请输入备注", trigger: "blur" }],
  147. },
  148. topinstitutionList: [], //供应商
  149. eduList: [], //教育类型
  150. disabledChange: false,
  151. };
  152. },
  153. watch: {
  154. "formData.costCatId": {
  155. handler(newVal, oldVal) {
  156. if (!this.disabledChange && this.formData.instId) {
  157. this.$set(this.formData, "instId", null);
  158. this.$set(this.formData, "bank", null);
  159. this.$set(this.formData, "bankAccount", null);
  160. this.$set(this.formData, "bankName", null);
  161. }
  162. if (newVal) {
  163. this.$api
  164. .topinstitutionlistByCat({
  165. costCatId: newVal,
  166. })
  167. .then((res) => {
  168. this.topinstitutionList = res.rows;
  169. });
  170. } else {
  171. this.topinstitutionList = [];
  172. }
  173. },
  174. },
  175. "formData.instId": {
  176. handler(newVal, oldVal) {
  177. if (!this.disabledChange && this.formData.educationTypeId) {
  178. this.$set(this.formData, "educationTypeId", null);
  179. }
  180. if (newVal) {
  181. this.$api
  182. .topcostinsttpbusinessList({
  183. costCatId: this.formData.costCatId,
  184. instId: this.formData.instId,
  185. })
  186. .then((res) => {
  187. this.eduList = res.data;
  188. });
  189. const INDEX = this.topinstitutionList.findIndex(
  190. (i) => i.instId == newVal
  191. );
  192. if (INDEX !== -1) {
  193. this.$set(
  194. this.formData,
  195. "bank",
  196. this.topinstitutionList[INDEX].bank
  197. );
  198. this.$set(
  199. this.formData,
  200. "bankAccount",
  201. this.topinstitutionList[INDEX].bankAccount
  202. );
  203. this.$set(
  204. this.formData,
  205. "bankName",
  206. this.topinstitutionList[INDEX].bankName
  207. );
  208. }
  209. } else {
  210. this.eduList = [];
  211. }
  212. },
  213. },
  214. "formData.educationTypeId": {
  215. handler(newVal, oldVal) {
  216. if (!this.disabledChange && this.formData.businessId) {
  217. this.$set(this.formData, "businessId", null);
  218. }
  219. },
  220. },
  221. },
  222. methods: {
  223. init() {
  224. if (this.activeData.title) {
  225. this.disabledChange = true;
  226. this.formData = Object.assign({}, this.activeData);
  227. setTimeout(() => {
  228. this.disabledChange = false;
  229. }, 300);
  230. } else {
  231. this.formData = {
  232. title: "",
  233. costCatId: "",
  234. instId: "",
  235. educationTypeId: "",
  236. businessId: "",
  237. remark: "",
  238. };
  239. }
  240. this.$nextTick(() => {
  241. this.$refs["formData"].clearValidate();
  242. });
  243. },
  244. close() {
  245. this.$refs["formData"].resetFields();
  246. },
  247. submitForm(type) {
  248. var self = this;
  249. this.$refs["formData"].validate((valid) => {
  250. if (valid) {
  251. let data = Object.assign({}, self.formData);
  252. data.settleType = 1;
  253. self.$emit("openSupplier", data);
  254. self.isShow = false;
  255. } else {
  256. return false;
  257. }
  258. });
  259. },
  260. changeFormDataBusiness(item) {
  261. this.formData.projectId = item.projectId;
  262. this.formData.businessName = item.businessName + item.projectName;
  263. },
  264. },
  265. computed: {
  266. ...mapGetters(["topinstcategoryList"]),
  267. businessList: function () {
  268. return function (id) {
  269. const INDEX = this.eduList.findIndex((i) => i.id == id);
  270. return INDEX !== -1 ? this.eduList[INDEX].businessList || [] : [];
  271. };
  272. },
  273. isShow: {
  274. get() {
  275. if (this.dialogVisible) {
  276. this.init();
  277. }
  278. return this.dialogVisible;
  279. },
  280. set(val) {
  281. this.$emit("update:dialogVisible", false);
  282. },
  283. },
  284. },
  285. };
  286. </script>
  287. <style lang="scss" scoped>
  288. .dis_play {
  289. display: flex;
  290. .gz {
  291. flex: 1;
  292. }
  293. .el-divider {
  294. height: auto;
  295. margin: 30px;
  296. }
  297. .el-date-editor--datetimerange.el-input,
  298. .el-date-editor--datetimerange.el-input__inner {
  299. width: 368px;
  300. }
  301. }
  302. .el-input {
  303. width: 220px;
  304. margin-right: 10px;
  305. }
  306. .el-select {
  307. width: 220px;
  308. margin-right: 10px;
  309. }
  310. </style>