detail.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <div class="app-container">
  3. <div class="title-container">
  4. <breadcrumb id="breadcrumb-container" class="breadcrumb-container"/>
  5. </div>
  6. <y-detail-page-layout @save="handleCreate" :edit-status="true" v-loading="vLoading" element-loading-text="处理中。。。">
  7. <div style="padding-top: 30px;">
  8. <el-tabs v-model="activeName">
  9. <el-tab-pane label="拜访详情" name="first">
  10. <el-form ref="postForm" :model="postForm" class="form-container" style="padding-left: 500px">
  11. <div>
  12. <div class="postInfo-container">
  13. <el-row>
  14. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  15. <el-form-item
  16. label="客户名字:"
  17. prop="customerId"
  18. label-width="180px"
  19. class="postInfo-container-item"
  20. :rules="{required: true, message: '请填选择客户名字', trigger: 'blur'}"
  21. >
  22. <el-select
  23. v-model="postForm.customerId"
  24. placeholder=""
  25. clearable
  26. filterable
  27. class="filter-item"
  28. style=" width: 100%"
  29. @change="getCustomerDetail"
  30. >
  31. <el-option
  32. v-for="item in customers"
  33. :key="item.id"
  34. :label="item.name"
  35. :value="item.id"
  36. />
  37. </el-select>
  38. </el-form-item>
  39. </el-col>
  40. </el-row>
  41. <el-row>
  42. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  43. <el-form-item
  44. label="客户部门:"
  45. prop="department"
  46. label-width="180px"
  47. class="postInfo-container-item"
  48. >
  49. <el-input style="width: 100%" :value="postForm.customerDepartment" readonly disabled/>
  50. </el-form-item>
  51. </el-col>
  52. </el-row>
  53. <el-row>
  54. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  55. <el-form-item
  56. label="客户科室:"
  57. prop="section"
  58. label-width="180px"
  59. class="postInfo-container-item"
  60. >
  61. <el-input style="width: 100%" :value="postForm.customerSection" readonly disabled/>
  62. </el-form-item>
  63. </el-col>
  64. </el-row>
  65. <el-row>
  66. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  67. <el-form-item
  68. label="客户职位:"
  69. prop="position"
  70. label-width="180px"
  71. class="postInfo-container-item"
  72. >
  73. <el-input style="width: 100%" :value="postForm.customerPosition" readonly disabled/>
  74. </el-form-item>
  75. </el-col>
  76. </el-row>
  77. </div>
  78. </div>
  79. <div>
  80. <div>
  81. <div class="postInfo-container">
  82. <el-row>
  83. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  84. <el-form-item
  85. label="拜访类型:"
  86. prop="visitType"
  87. label-width="180px"
  88. class="postInfo-container-item"
  89. :rules="{required: true, message: '选择拜访类型', trigger: 'blur'}"
  90. >
  91. <el-select clearable style="width: 100%" v-model="postForm.visitType" placeholder="拜访类型">
  92. <el-option key="0" label="初访" value="初访"/>
  93. <el-option key="1" label="回访" value="回访"/>
  94. </el-select>
  95. </el-form-item>
  96. </el-col>
  97. </el-row>
  98. </div>
  99. </div>
  100. <div>
  101. <div class="postInfo-container">
  102. <el-row>
  103. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  104. <el-form-item
  105. label="拜访日期:"
  106. prop="visitTime"
  107. :rules="{required: true, message: '请选择日期', trigger: 'blur'}"
  108. label-width="180px"
  109. class="postInfo-container-item"
  110. >
  111. <el-date-picker
  112. v-model="postForm.visitTime"
  113. type="date"
  114. value-format="yyyy-MM-dd"
  115. style="width: 100%"
  116. placeholder="选择日期"
  117. />
  118. </el-form-item>
  119. </el-col>
  120. </el-row>
  121. </div>
  122. </div>
  123. <div>
  124. <div class="postInfo-container">
  125. <el-row>
  126. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  127. <el-form-item
  128. label="拜访地点:"
  129. prop="spot"
  130. label-width="180px"
  131. class="postInfo-container-item"
  132. >
  133. <el-input v-model="postForm.spot" class="filter-item"/>
  134. </el-form-item>
  135. </el-col>
  136. </el-row>
  137. </div>
  138. </div>
  139. <div>
  140. <div class="postInfo-container">
  141. <el-row>
  142. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  143. <el-form-item
  144. label="沟通内容:"
  145. prop="content"
  146. label-width="180px"
  147. class="postInfo-container-item"
  148. >
  149. <el-input type="textarea" v-model="postForm.content" class="filter-item" placeholder="200字符" :autosize="{ minRows: 8, maxRows: 8}"/>
  150. </el-form-item>
  151. </el-col>
  152. </el-row>
  153. </div>
  154. </div>
  155. </div>
  156. </el-form>
  157. </el-tab-pane>
  158. </el-tabs>
  159. </div>
  160. </y-detail-page-layout>
  161. </div>
  162. </template>
  163. <script>
  164. import Breadcrumb from '@/components/Breadcrumb'
  165. import YDetailPageLayout from '@/components/YDetailPageLayout'
  166. export default {
  167. name: 'visitDetail',
  168. components: {
  169. Breadcrumb,
  170. YDetailPageLayout
  171. },
  172. data() {
  173. return {
  174. type: 'detail',
  175. postForm: {
  176. customerId:null,
  177. customerDepartment:null,
  178. customerSection:null,
  179. customerPosition:null
  180. },
  181. visitId : this.$route.query.id,
  182. activeName: 'first',
  183. vLoading: false,
  184. listQuery:{},
  185. customers:[]
  186. }
  187. },
  188. created() {
  189. this.getCustomer();
  190. this.getDetail();
  191. },
  192. methods: {
  193. getCustomerDetail(){
  194. this.$api.customer.detail(this.postForm.customerId).then(res =>{
  195. this.postForm.customerDepartment = res.data.department;
  196. this.postForm.customerPosition = res.data.position;
  197. this.postForm.customerSection = res.data.section;
  198. })
  199. },
  200. getDetail() {
  201. if (this.visitId) {
  202. this.$api.visit.detail(this.visitId).then(res => {
  203. this.postForm = res.data;
  204. });
  205. }
  206. },
  207. getCustomer(){
  208. const that = this;
  209. that.$api.customer.simpleAll().then(data => {
  210. if (data.code === 200) {
  211. that.customers = data.data
  212. } else {
  213. this.$message({
  214. type: 'error',
  215. message: data.msg
  216. })
  217. }
  218. })
  219. },
  220. handleCreate() {
  221. this.$refs.postForm.validate(valid => {
  222. if (valid) {
  223. if (this.visitId) {
  224. this.$api.visit.edit(Object.assign({}, this.postForm, {
  225. })).then(res => {
  226. if (res.code === 200) {
  227. this.$notify({
  228. title: '成功',
  229. message: '保存成功',
  230. type: 'success',
  231. duration: 2000
  232. });
  233. const back = this.$route.query.back;
  234. if (back) {
  235. this.$router.push(back)
  236. }
  237. this.initData();
  238. this.vLoading = false
  239. }
  240. }).catch(() => {
  241. this.vLoading = false
  242. })
  243. } else {
  244. this.$api.visit.add(Object.assign({}, this.postForm, {
  245. })).then(res => {
  246. if (res.code === 200) {
  247. this.$notify({
  248. title: '成功',
  249. message: '新增成功',
  250. type: 'success',
  251. duration: 2000
  252. });
  253. const back = this.$route.query.back;
  254. if (back) {
  255. this.$router.push(back)
  256. }
  257. this.initData();
  258. this.vLoading = false
  259. }
  260. }).catch(() => {
  261. this.vLoading = false
  262. })
  263. }
  264. }
  265. })
  266. },
  267. }
  268. }
  269. </script>
  270. <style lang="scss" scoped>
  271. </style>