DetailsContact.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <div style="height: 100%">
  3. <vab-query-form>
  4. <vab-query-form-left-panel :span="12">
  5. <el-input
  6. v-model="queryForm.cuctName"
  7. placeholder="请输入姓名"
  8. prefix-icon="el-icon-search"
  9. style="width: 50%"
  10. @keyup.enter.native="fetchData" />
  11. </vab-query-form-left-panel>
  12. <vab-query-form-right-panel :span="12">
  13. <el-button icon="el-icon-plus" @click="handleAddContact">新建联系人</el-button>
  14. <el-button @click="handleSelectContact">关联</el-button>
  15. <el-button type="danger" @click="handleDisassociation">解除关联</el-button>
  16. </vab-query-form-right-panel>
  17. </vab-query-form>
  18. <el-table v-loading="listLoading" :data="contactList" height="calc(100% - 42px)" @selection-change="setSelectRows">
  19. <el-table-column align="center" type="selection" />
  20. <el-table-column align="center" label="姓名" prop="cuctName" show-overflow-tooltip />
  21. <el-table-column align="center" label="岗位" prop="postion" show-overflow-tooltip />
  22. <el-table-column align="center" label="电话" prop="telephone" show-overflow-tooltip />
  23. <el-table-column align="center" label="微信" prop="wechat" show-overflow-tooltip />
  24. <el-table-column align="center" label="办公地点" prop="officeLocation" show-overflow-tooltip />
  25. <!-- <el-table-column align="center" label="邮箱" prop="email" show-overflow-tooltip />-->
  26. <!-- <el-table-column align="center" label="是否决策人">-->
  27. <!-- <template slot-scope="scope">-->
  28. <!-- <el-switch v-model="scope.row.isDecision" active-value="10" disabled inactive-value="20" />-->
  29. <!-- </template>-->
  30. <!-- </el-table-column>-->
  31. <el-table-column align="center" label="操作" show-overflow-tooltip>
  32. <template slot-scope="scope">
  33. <el-button v-if="scope.row.contactId !== primacyContactId" type="text" @click="setPrimacyContact(scope.row)">
  34. 设为首要联系人
  35. </el-button>
  36. <span v-else>首要联系人</span>
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. <!-- 选择客户联系人弹窗 -->
  41. <select-contact
  42. ref="selectContact"
  43. :default-customer="customerInfo"
  44. :query-params="queryContact"
  45. @save="selectContact" />
  46. <!-- 新建联系人弹窗 -->
  47. <customer-contact ref="contact" @contactSave="handleSelectContact" />
  48. </div>
  49. </template>
  50. <script>
  51. import businessApi from '@/api/proj/business'
  52. import businessContactApi from '@/api/proj/businessContact'
  53. import SelectContact from '@/components/select/SelectCustomerContact'
  54. import CustomerContact from '@/views/customer/components/Contact'
  55. export default {
  56. name: 'Records',
  57. components: { SelectContact, CustomerContact },
  58. props: {
  59. // 项目Id
  60. busId: {
  61. type: Number,
  62. default: 0,
  63. },
  64. // 主要联系人Id
  65. primacyContactId: {
  66. type: Number,
  67. default: 0,
  68. },
  69. // 客户信息{ custId: id, custName: custName}
  70. customerInfo: {
  71. type: Object,
  72. default() {
  73. return {}
  74. },
  75. },
  76. },
  77. data() {
  78. return {
  79. queryForm: {
  80. cuctName: undefined,
  81. pageNum: 1,
  82. pageSize: 9999,
  83. },
  84. listLoading: false,
  85. selectRows: [],
  86. contactList: [],
  87. queryContact: {},
  88. }
  89. },
  90. mounted() {
  91. // this.fetchData()
  92. },
  93. methods: {
  94. handleAddContact() {
  95. this.$refs.contact.contactForm.custId = this.customerInfo.custId
  96. this.$refs.contact.contactForm.custName = this.customerInfo.custName
  97. this.$refs.contact.contactVisible = true
  98. },
  99. handleSelectContact() {
  100. this.queryContact.custId = this.customerInfo.custId
  101. if (!this.queryContact.custId) {
  102. this.$message.warning('请先选择客户')
  103. return
  104. }
  105. this.$refs.selectContact.open()
  106. },
  107. async selectContact(val) {
  108. if (val && val.length > 0) {
  109. let form = {
  110. busId: this.busId,
  111. contactIds: val.map((item) => item.id),
  112. }
  113. const { msg } = await businessContactApi.doAdd(form)
  114. this.$baseMessage(msg, 'success')
  115. await this.fetchData()
  116. this.$emit('fetch-data')
  117. }
  118. },
  119. handleDisassociation() {
  120. if (this.selectRows.length > 0) {
  121. const ids = this.selectRows.map((item) => item.id)
  122. this.$baseConfirm('你确定要解除关联选中项吗', null, async () => {
  123. const { msg } = await businessContactApi.doDelete({ ids })
  124. this.$baseMessage(msg, 'success')
  125. await this.fetchData()
  126. this.$emit('fetch-data')
  127. })
  128. } else {
  129. this.$baseMessage('未选中任何行', 'error')
  130. return false
  131. }
  132. },
  133. async setPrimacyContact(row) {
  134. let form = {
  135. id: this.busId,
  136. contactId: row.contactId,
  137. contactName: row.cuctName,
  138. contactPostion: row.telephone,
  139. contactTelephone: row.cuctName,
  140. }
  141. const { msg } = await businessApi.setPrimacyContact(form)
  142. this.$baseMessage(msg, 'success')
  143. this.$emit('fetch-data')
  144. },
  145. setSelectRows(val) {
  146. this.selectRows = val
  147. },
  148. async fetchData() {
  149. this.listLoading = true
  150. this.queryForm.busId = this.busId
  151. const {
  152. data: { list },
  153. } = await businessContactApi.getList(this.queryForm)
  154. this.contactList = list
  155. this.listLoading = false
  156. },
  157. },
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .follow {
  162. height: 100%;
  163. padding: 10px 20px;
  164. overflow: auto;
  165. > li {
  166. display: flex;
  167. + li {
  168. margin-top: 10px;
  169. }
  170. }
  171. .date {
  172. width: 100px;
  173. display: flex;
  174. flex-direction: column;
  175. align-items: center;
  176. h2,
  177. h3 {
  178. margin: 0;
  179. }
  180. h2 {
  181. font-size: 26px;
  182. line-height: 32px;
  183. }
  184. }
  185. .content {
  186. flex: 1;
  187. list-style: none;
  188. > li {
  189. border: 1px solid rgb(215, 232, 244);
  190. background: rgb(247, 251, 254);
  191. border-radius: 4px;
  192. padding: 8px;
  193. overflow: hidden;
  194. .text-container {
  195. display: flex;
  196. }
  197. .comments {
  198. padding-left: 60px;
  199. margin-top: 10px;
  200. max-height: 190px;
  201. overflow: auto;
  202. li {
  203. display: flex;
  204. border-top: 1px solid #e3e5e7;
  205. .text {
  206. flex: 1;
  207. padding: 0 10px;
  208. p {
  209. font-weight: 500;
  210. margin: 0;
  211. line-height: 32px;
  212. }
  213. p:first-child {
  214. line-height: 30px;
  215. font-weight: bold;
  216. }
  217. p:last-child {
  218. font-size: 12px;
  219. color: #9499a0;
  220. text-align: right;
  221. }
  222. }
  223. }
  224. }
  225. + li {
  226. margin-top: 10px;
  227. }
  228. }
  229. .user-avatar {
  230. font-size: 40px;
  231. }
  232. .text {
  233. flex: 1;
  234. padding-left: 20px;
  235. padding-right: 10px;
  236. p {
  237. font-weight: 500;
  238. margin: 0;
  239. line-height: 32px;
  240. span {
  241. color: #1d66dc;
  242. }
  243. }
  244. .action {
  245. display: flex;
  246. justify-content: space-between;
  247. span:first-child {
  248. font-weight: bold;
  249. color: #333;
  250. }
  251. }
  252. .footer {
  253. display: flex;
  254. justify-content: space-between;
  255. align-items: center;
  256. }
  257. }
  258. }
  259. }
  260. .no-follow {
  261. height: 100%;
  262. width: 100%;
  263. display: flex;
  264. align-items: center;
  265. justify-content: center;
  266. font-size: 12px;
  267. color: rgba(0, 0, 0, 0.65);
  268. }
  269. </style>