You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

215 lines
6.7 KiB

  1. <template>
  2. <CustomDrawer ref="IndustryEdit" title="市场调研" :destroyOnClose="true">
  3. <a-form-model ref="ruleForm" :model="form" :rules="rules" layout="vertical">
  4. <a-form-model-item label="所在行业" prop="industry">
  5. <a-select
  6. v-model="form.industry"
  7. @change="handleChangeIndustry"
  8. >
  9. <a-select-option
  10. v-for="item in industryTypes"
  11. :key="item.code + item.id"
  12. :value="item.id"
  13. >{{ item.name }}</a-select-option
  14. >
  15. </a-select>
  16. </a-form-model-item>
  17. <a-form-model-item label="从业领域" prop="categoryId">
  18. <a-select
  19. v-model="form.categoryId"
  20. @change="getIndustryCategoryCheck"
  21. >
  22. <a-select-option
  23. v-for="item in industryTypesTwo"
  24. :key="item.code + item.id"
  25. :value="item.id"
  26. >{{ item.name }}</a-select-option
  27. >
  28. </a-select>
  29. </a-form-model-item>
  30. <a-form-model-item
  31. label="领域详细"
  32. class="specailitem"
  33. v-if="industryTypesCheck.length > 0"
  34. >
  35. <a-checkbox-group
  36. v-model="form.childCategoryIds"
  37. name="checkboxgroup"
  38. :options="industryTypesCheck"
  39. />
  40. </a-form-model-item>
  41. <a-form-model-item label="主营业务">
  42. <a-input v-model.trim="form.businessScope" />
  43. </a-form-model-item>
  44. <a-form-model-item label="行业地位">
  45. <a-input v-model.trim="form.rank" />
  46. </a-form-model-item>
  47. <a-form-model-item label="市场占比">
  48. <a-input-number
  49. v-model="form.marketShare"
  50. :min="0"
  51. :max="100"
  52. :precision="0"
  53. style="width:95%;"
  54. />%
  55. </a-form-model-item>
  56. <a-form-model-item label="市场客户">
  57. <a-input v-model.trim="form.marketCustomer" />
  58. </a-form-model-item>
  59. <a-form-model-item label="年度销售金额">
  60. <a-input-number v-model="form.yearSalesAmount" :min="0" :precision="2" style="width:100%;" />
  61. </a-form-model-item>
  62. <a-form-model-item label="年度销售数量">
  63. <a-input-number v-model="form.yearSalesNum" :min="0" :max="2000000000" :precision="0" style="width:100%;" />
  64. </a-form-model-item>
  65. </a-form-model>
  66. <a-space :size="10">
  67. <a-button type="primary" :loading="loading" @click="handleSave">确认</a-button>
  68. <a-button :loading="loading" @click="hideDrawer">取消</a-button>
  69. </a-space>
  70. </CustomDrawer>
  71. </template>
  72. <script>
  73. import { putUpdateIndustry, putUpdateProjectIndustry } from '@/services/fileManagement/customer';
  74. import {
  75. getIndustryCategoryById,
  76. } from '@/services/fileManagement/industryCategory';
  77. export default {
  78. props: {
  79. isCompany: {
  80. type: Boolean,
  81. default: true
  82. }
  83. },
  84. data() {
  85. return {
  86. form: {},
  87. rules: {
  88. industry:[
  89. {required:true,message:'请选择行业',trigger:'change'}
  90. ],
  91. categoryId:[
  92. // {required:true,message:'请选择领域',trigger:'change'}
  93. ]
  94. },
  95. industryTypes: [],
  96. industryTypesMap: {},
  97. industryTypesTwo: [],
  98. industryTypesTwoMap: {},
  99. industryTypesCheck: [],
  100. loading: false,
  101. id: ''
  102. };
  103. },
  104. mounted() {
  105. this.getDropDown();
  106. },
  107. methods: {
  108. showDrawer(id, industryInfo) {
  109. this.id = id;
  110. const categoryIds = industryInfo.categoryIds || []
  111. this.form = {
  112. industry: categoryIds[0],
  113. categoryId: categoryIds[1],
  114. categoryName: industryInfo.categoryName,
  115. childCategoryIds: industryInfo.domainDetail?.split(','),
  116. businessScope: industryInfo.businessScope,
  117. marketShare: industryInfo.marketShare,
  118. rank: industryInfo.rank,
  119. marketCustomer: industryInfo.marketCustomer,
  120. yearSalesAmount: industryInfo.yearSalesAmount,
  121. yearSalesNum: industryInfo.yearSalesNum,
  122. };
  123. if (categoryIds.length > 0) {
  124. this.getIndustryCategoryChild(categoryIds[0], () => {
  125. this.getIndustryCategoryCheck(categoryIds[1])
  126. });
  127. }
  128. this.$refs.IndustryEdit.showDrawer();
  129. },
  130. hideDrawer() {
  131. this.$refs.IndustryEdit.hideDrawer();
  132. },
  133. getDropDown() {
  134. getIndustryCategoryById(0).then((res) => {
  135. res.forEach((item) => {
  136. this.industryTypesMap[item.id] = item;
  137. });
  138. this.industryTypes = res;
  139. });
  140. },
  141. handleChangeIndustry(id) {
  142. this.form.categoryId = '';
  143. this.form.childCategoryIds = [];
  144. this.getIndustryCategoryChild(id);
  145. },
  146. getIndustryCategoryChild(id, callback) {
  147. this.industryTypesTwo = [];
  148. this.industryTypesCheck = [];
  149. getIndustryCategoryById(id).then((res) => {
  150. res.forEach((item) => {
  151. this.industryTypesTwoMap[item.id] = item;
  152. });
  153. this.industryTypesTwo = res;
  154. callback && callback();
  155. });
  156. },
  157. getIndustryCategoryCheck(id) {
  158. this.industryTypesCheck = this.industryTypesTwoMap[id].attributes;
  159. },
  160. getLogo(list) {
  161. this.form.logo = list;
  162. },
  163. handleSave() {
  164. this.$refs.ruleForm.validate((valid) => {
  165. if (valid) {
  166. let categoryName = '';
  167. if (this.form.industry) {
  168. categoryName = `${this.industryTypesMap[this.form.industry].name}`;
  169. }
  170. if (this.form.categoryId) {
  171. categoryName = `${this.industryTypesMap[this.form.industry].name}|${this.industryTypesTwoMap[this.form.categoryId].name}`;
  172. }
  173. const params = {
  174. categoryId: this.form.categoryId || this.form.industry,
  175. categoryName,
  176. domainDetail: this.form.childCategoryIds.join(),
  177. businessScope: this.form.businessScope,
  178. marketShare: this.form.marketShare,
  179. marketCustomer: this.form.marketCustomer,
  180. yearSalesAmount: this.form.yearSalesAmount,
  181. yearSalesNum: this.form.yearSalesNum,
  182. rank: this.form.rank
  183. };
  184. this.loading = true;
  185. if (this.isCompany) {
  186. putUpdateIndustry(this.id, params)
  187. .then((res) => {
  188. this.$message.success('保存成功');
  189. this.$emit('ok');
  190. this.hideDrawer();
  191. })
  192. .finally(() => {
  193. this.loading = false;
  194. });
  195. } else {
  196. putUpdateProjectIndustry(this.id, params)
  197. .then((res) => {
  198. this.$message.success('保存成功');
  199. this.$emit('ok');
  200. this.hideDrawer();
  201. })
  202. .finally(() => {
  203. this.loading = false;
  204. });
  205. }
  206. }
  207. });
  208. },
  209. },
  210. };
  211. </script>
  212. <style></style>