detail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <div class="app-container">
  3. <div class="title-container">
  4. <breadcrumb id="breadcrumb-container" class="breadcrumb-container"/>
  5. </div>
  6. <div style="padding-top: 30px;">
  7. <el-tabs v-model="activeName" type="border-card">
  8. <el-tab-pane label="拜访详情" name="first">
  9. <y-detail-page-layout @save="handleCreate" :edit-status="true" v-loading="vLoading" element-loading-text="处理中。。。" :list-query="listQuery">
  10. <el-form ref="postForm" :model="postForm" class="form-container" style="padding-left: 200px;">
  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:360px"
  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="level"
  46. label-width="180px"
  47. class="postInfo-container-item"
  48. >
  49. <el-input style="width:360px" :value="postForm.customerLevel" 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="department"
  58. label-width="180px"
  59. class="postInfo-container-item"
  60. >
  61. <el-input style="width:360px" :value="postForm.customerDepartment" 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="section"
  70. label-width="180px"
  71. class="postInfo-container-item"
  72. >
  73. <el-input style="width:360px" :value="postForm.customerSection" readonly disabled/>
  74. </el-form-item>
  75. </el-col>
  76. </el-row>
  77. <el-row>
  78. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  79. <el-form-item
  80. label="客户职位:"
  81. prop="position"
  82. label-width="180px"
  83. class="postInfo-container-item"
  84. >
  85. <el-input style="width:360px" :value="postForm.customerPosition" readonly disabled/>
  86. </el-form-item>
  87. </el-col>
  88. </el-row>
  89. </div>
  90. </div>
  91. <div>
  92. <div>
  93. <div class="postInfo-container">
  94. <el-row>
  95. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  96. <el-form-item
  97. label="拜访类型:"
  98. prop="visitType"
  99. label-width="180px"
  100. class="postInfo-container-item"
  101. :rules="{required: true, message: '选择拜访类型', trigger: 'blur'}"
  102. >
  103. <el-select clearable style="width:360px" v-model="postForm.visitType" placeholder="拜访类型">
  104. <el-option key="0" label="初访" value="初访"/>
  105. <el-option key="1" label="回访" value="回访"/>
  106. </el-select>
  107. </el-form-item>
  108. </el-col>
  109. </el-row>
  110. </div>
  111. </div>
  112. <div>
  113. <div class="postInfo-container">
  114. <el-row>
  115. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  116. <el-form-item
  117. label="拜访日期:"
  118. prop="visitTime"
  119. :rules="{required: true, message: '请选择日期', trigger: 'blur'}"
  120. label-width="180px"
  121. class="postInfo-container-item"
  122. >
  123. <el-date-picker
  124. v-model="postForm.visitTime"
  125. type="date"
  126. value-format="yyyy-MM-dd"
  127. style="width:360px"
  128. placeholder="选择日期"
  129. />
  130. </el-form-item>
  131. </el-col>
  132. </el-row>
  133. </div>
  134. </div>
  135. <div>
  136. <div class="postInfo-container">
  137. <el-row>
  138. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  139. <el-form-item
  140. label="拜访地点:"
  141. prop="spot"
  142. label-width="180px"
  143. class="postInfo-container-item"
  144. >
  145. <el-input v-model="postForm.spot" style="width:360px" class="filter-item"/>
  146. </el-form-item>
  147. </el-col>
  148. </el-row>
  149. </div>
  150. </div>
  151. <div>
  152. <div class="postInfo-container">
  153. <el-row>
  154. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  155. <el-form-item
  156. label="沟通内容:"
  157. prop="content"
  158. label-width="180px"
  159. class="postInfo-container-item"
  160. >
  161. <el-input type="textarea" style="width:360px" v-model="postForm.content" class="filter-item" placeholder="200字符" :autosize="{ minRows: 8, maxRows: 8}"/>
  162. </el-form-item>
  163. </el-col>
  164. </el-row>
  165. </div>
  166. </div>
  167. </div>
  168. </el-form>
  169. </y-detail-page-layout>
  170. </el-tab-pane>
  171. <el-tab-pane :lazy="paneLazy" name="replyList">
  172. <span slot="label">
  173. 回复记录<el-badge :is-dot="isDot" class="item"></el-badge>
  174. </span>
  175. <y-page-list-layout :page-list="pageData" :page-para="listQuery" :get-page-list="getList">
  176. <template slot="left">
  177. <el-button
  178. class="filter-item"
  179. style="margin-left: 10px;"
  180. type="success"
  181. round
  182. :disabled="disable"
  183. @click="dialogVisible = true"
  184. >
  185. 回复
  186. </el-button>
  187. </template>
  188. <parentTable
  189. v-loading="listLoading"
  190. :data="pageData.records"
  191. slot="table"
  192. style="width: 100%;"
  193. >
  194. <el-table-column label="内容" align="center" width="500">
  195. <template slot-scope="{row}">
  196. <span>{{ row.content }}</span>
  197. </template>
  198. </el-table-column>
  199. <el-table-column label="回复人" align="center">
  200. <template slot-scope="{row}">
  201. <span>{{ row.replier }}</span>
  202. </template>
  203. </el-table-column>
  204. <el-table-column label="接收人" align="center">
  205. <template slot-scope="{row}">
  206. <span>{{ row.receiver }}</span>
  207. </template>
  208. </el-table-column>
  209. <el-table-column label="状态" align="center">
  210. <template slot-scope="{row}">
  211. <el-tag type="error">{{row.state?'已读':'未读'}}</el-tag>
  212. </template>
  213. </el-table-column>
  214. <el-table-column label="回复时间" align="center">
  215. <template slot-scope="{row}">
  216. <span>{{ row.created}}</span>
  217. </template>
  218. </el-table-column>
  219. </parentTable>
  220. </y-page-list-layout>
  221. </el-tab-pane>
  222. </el-tabs>
  223. <el-dialog
  224. title="回复内容"
  225. :visible.sync="dialogVisible"
  226. width="30%"
  227. custom-class="tag-class"
  228. >
  229. <el-input
  230. type="textarea"
  231. :rows="8"
  232. placeholder="请输入内容"
  233. v-model="replyForm.content"
  234. />
  235. <span slot="footer" class="dialog-footer">
  236. <el-button @click="dialogVisible = false">取 消</el-button>
  237. <el-button type="primary" @click="replay">确 定</el-button>
  238. </span>
  239. </el-dialog>
  240. </div>
  241. </div>
  242. </template>
  243. <script>
  244. import Breadcrumb from '@/components/Breadcrumb'
  245. import YDetailPageLayout from '@/components/YDetailPageLayout'
  246. export default {
  247. name: 'visitDetail',
  248. components: {
  249. Breadcrumb,
  250. YDetailPageLayout
  251. },
  252. data() {
  253. return {
  254. disable:null,
  255. paneLazy:true,
  256. isDot:null,
  257. replyForm: {
  258. id:null,
  259. content:null,
  260. bizType:'MARKET_VISIT_REPLY',
  261. bizTableId:this.$route.query.id,
  262. parentId:null,
  263. replierId:null,
  264. receiverId:null
  265. },
  266. dialogVisible: false,
  267. activeName: 'first',
  268. tableKey: 0,
  269. pageData: {},
  270. total: 20,
  271. listLoading: true,
  272. listQuery: {
  273. page: 1,
  274. size: 10,
  275. descs: 'id',
  276. },
  277. listQueryKey: 'keyword',
  278. postForm: {
  279. customerId:null,
  280. customerDepartment:null,
  281. customerSection:null,
  282. customerPosition:null,
  283. customerLevel:null,
  284. customerManagerId:null,
  285. userId:null
  286. },
  287. visitId : this.$route.query.id,
  288. vLoading: false,
  289. customers:[],
  290. lastReplier:null,
  291. lastReceiver:null,
  292. }
  293. },
  294. created() {
  295. this.listQuery = this.$route.query.listQuery;
  296. this.activeName = this.$route.query.activeName;
  297. this.getCustomer();
  298. this.getDetail();
  299. this.getNotRead();
  300. },
  301. watch:{
  302. activeName: {
  303. handler(newValue){
  304. if (newValue === 'replyList'){
  305. this.disable = this.$route.query.id===null?true:false;
  306. this.getList();
  307. this.isDot=false;
  308. }
  309. }
  310. }
  311. },
  312. methods: {
  313. getNotRead(){
  314. this.replyForm.receiverId = this.$store.getters.userInfo.id;
  315. this.replyForm.bizType = 'MARKET_VISIT_REPLY';
  316. this.replyForm.bizTableId = this.$route.query.id;
  317. this.$api.businessReply.notRead(this.replyForm).then(res => {
  318. if (res.code === 200){
  319. this.isDot = res.data !== 0;
  320. }
  321. });
  322. },
  323. replay(){
  324. if (this.lastReplier!=null && this.lastReceiver!=null){
  325. this.replyForm.receiverId = this.lastReplier;
  326. this.replyForm.replierId = this.$store.getters.userInfo.id;
  327. }
  328. if (this.lastReplier === this.$store.getters.userInfo.id){
  329. this.$notify({
  330. title: '错误',
  331. message: '不能回复给自己',
  332. type: 'error',
  333. duration: 2000
  334. });
  335. this.dialogVisible = false;
  336. return;
  337. }
  338. if (this.postForm.userId ===this.$store.getters.userInfo.id && this.lastReceiver===null){
  339. this.$notify({
  340. title: '错误',
  341. message: '不能回复给自己',
  342. type: 'error',
  343. duration: 2000
  344. });
  345. this.dialogVisible = false;
  346. return;
  347. }
  348. this.replyForm.replierId = this.$store.getters.userInfo.id;
  349. if (this.lastReceiver===null){
  350. this.replyForm.receiverId = this.postForm.userId;
  351. }
  352. this.$api.businessReply.add(Object.assign({}, this.replyForm, {
  353. })).then(res => {
  354. if (res.code === 200) {
  355. this.$notify({
  356. title: '成功',
  357. message: '回复成功',
  358. type: 'success',
  359. duration: 2000
  360. });
  361. this.dialogVisible = false;
  362. this.getList();
  363. this.vLoading = false
  364. }
  365. }).catch(() => {
  366. this.vLoading = false
  367. })
  368. },
  369. getList() {
  370. const that = this;
  371. this.listLoading = true;
  372. this.$api.businessReply.list(Object.assign({bizType:'MARKET_VISIT_REPLY', bizTableId:this.visitId}, that.listQuery)).then((res) => {
  373. that.pageData = res.data;
  374. this.lastReplier = res.data.records[0].replierId;
  375. this.lastReceiver = res.data.records[0].receiverId;
  376. setTimeout(() => {
  377. that.listLoading = false
  378. }, 200);
  379. })
  380. .catch(() => {
  381. that.listLoading = false
  382. })
  383. },
  384. getCustomerDetail(){
  385. this.$api.customer.detail(this.postForm.customerId).then(res =>{
  386. this.postForm.customerDepartment = res.data.department;
  387. this.postForm.customerPosition = res.data.position;
  388. this.postForm.customerSection = res.data.section;
  389. this.postForm.customerLevel = res.data.level;
  390. })
  391. },
  392. getDetail() {
  393. if (this.visitId) {
  394. this.$api.visit.detail(this.visitId).then(res => {
  395. this.postForm = res.data;
  396. });
  397. }
  398. },
  399. getCustomer(){
  400. const that = this;
  401. that.$api.customer.simpleAll().then(data => {
  402. if (data.code === 200) {
  403. that.customers = data.data
  404. } else {
  405. this.$message({
  406. type: 'error',
  407. message: data.msg
  408. })
  409. }
  410. })
  411. },
  412. handleCreate() {
  413. this.$refs.postForm.validate(valid => {
  414. if (valid) {
  415. if (this.visitId) {
  416. this.$api.visit.edit(Object.assign({}, this.postForm, {
  417. })).then(res => {
  418. if (res.code === 200) {
  419. this.$notify({
  420. title: '成功',
  421. message: '保存成功',
  422. type: 'success',
  423. duration: 2000
  424. });
  425. const back = this.$route.query.back;
  426. if (back) {
  427. this.$router.push(back);
  428. }
  429. this.initData();
  430. this.vLoading = false
  431. }
  432. }).catch(() => {
  433. this.vLoading = false
  434. })
  435. } else {
  436. this.$api.visit.add(Object.assign({}, this.postForm, {
  437. })).then(res => {
  438. if (res.code === 200) {
  439. this.$notify({
  440. title: '成功',
  441. message: '新增成功',
  442. type: 'success',
  443. duration: 2000
  444. });
  445. const back = this.$route.query.back;
  446. if (back) {
  447. this.$router.push(back)
  448. }
  449. this.initData();
  450. this.vLoading = false
  451. }
  452. }).catch(() => {
  453. this.vLoading = false
  454. })
  455. }
  456. }
  457. })
  458. },
  459. }
  460. }
  461. </script>
  462. <style lang="scss" scoped>
  463. </style>