insurerDialog.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <!--
  2. maintenance 选择供应商
  3. -->
  4. <template>
  5. <el-dialog title="选择型号" :visible.sync="dialog.insurer" width="1000px">
  6. <div>
  7. <div id="firm">
  8. <div class="title-search query-form" style="padding:10px;margin-bottom: 10px;">
  9. <el-input
  10. placeholder="输入厂家名称进行查找"
  11. v-model="search"
  12. size="small"
  13. style="width:300px; margin-right: 10px;"
  14. clearable
  15. ></el-input>
  16. <el-button size="small" @click="filterSearch">查找</el-button>
  17. </div>
  18. <el-radio-group v-model="radio" style="width:100%;">
  19. <el-table border class="data-table" ref="maintenance" :data="tableData" style="width: 100%" height="300px">
  20. <el-table-column header-align='center' label="供应商名称">
  21. <template slot-scope="scope">
  22. <el-tooltip :content="scope.row.name" placement="top">
  23. <el-radio v-model="radio" :label="scope.row">{{scope.row.name}}</el-radio>
  24. </el-tooltip>
  25. </template>
  26. </el-table-column>
  27. <el-table-column header-align='center' prop="website" label="网址"></el-table-column>
  28. <el-table-column header-align='center' prop="man" label="联系人"></el-table-column>
  29. <el-table-column header-align='center' prop="phone" label="联系电话"></el-table-column>
  30. <el-table-column header-align='center' prop="faxes" label="传真"></el-table-column>
  31. <el-table-column header-align='center' prop="email" label="电子邮件"></el-table-column>
  32. </el-table>
  33. </el-radio-group>
  34. <div class="right">
  35. <my-pagination :page="page" @change="changePage" style="margin-top:10px;"></my-pagination>
  36. </div>
  37. <p style="height:40px;line-height:40px;text-align:center;color:#9E9E9E;">
  38. 找不到想要的型号? 赶快去
  39. <i style="color:#46B0FF;cursor: pointer;">厂家库</i>维护吧
  40. </p>
  41. </div>
  42. </div>
  43. <div slot="footer">
  44. <el-button
  45. type="primary"
  46. @click="getChange"
  47. >确 定</el-button>
  48. </div>
  49. </el-dialog>
  50. </template>
  51. <script>
  52. import myPagination from "@/components/common/myPagination";
  53. import { getLib } from "@/api/scan/request"
  54. import tools from "@/utils/scan/tools"
  55. export default {
  56. components: {
  57. myPagination
  58. },
  59. props: {
  60. dialog: {
  61. type: Object,
  62. default: function () {
  63. return {
  64. insurer: true
  65. };
  66. }
  67. }
  68. },
  69. data() {
  70. return {
  71. search: "", //搜索文案
  72. radio: "",
  73. tableData: [],
  74. page: {
  75. size: 10,
  76. sizes: [10, 30, 50, 100, 150, 200],
  77. total: 0,
  78. currentPage: 1
  79. },
  80. projectId: this.$route.query.projId,
  81. };
  82. },
  83. created() {
  84. // this.getData()
  85. },
  86. mounted() { },
  87. methods: {
  88. //过滤
  89. filterSearch() {
  90. this.tableData = this.allData.map(item => {
  91. if (item.name.indexOf(this.search) != -1) {
  92. return item
  93. } else {
  94. return undefined
  95. }
  96. }).filter(cb => cb)
  97. },
  98. getData() {
  99. console.log("insurer")
  100. this.page = {
  101. size: 10,
  102. sizes: [10, 30, 50, 100, 150, 200],
  103. total: 0,
  104. currentPage: 1
  105. }
  106. getLib({ "type": ["insurance"] }).then(res => {
  107. if (res.data.result == "success") {
  108. let data = res.data.content.insurance.map(item => {
  109. if (item.contacts && item.contacts.length) {
  110. item.contacts.map(child => {
  111. if (child.projectId == this.projectId) {
  112. item.phone = child.phone
  113. item.man = child.name
  114. item.fox = child.fox
  115. item.email = child.email
  116. }
  117. return child
  118. })
  119. }
  120. if (!item.man) {
  121. item.man = "--"
  122. item.phone = "--"
  123. item.fox = "--"
  124. item.email = "--"
  125. }
  126. return item
  127. })
  128. this.allData = tools.deepCopy(data)
  129. this.tableData = this.pagination(this.page.currentPage, this.page.size, this.allData)
  130. this.page.total = data.length
  131. } else {
  132. this.$message.error("请求失败:" + res.data.resultMsg)
  133. }
  134. })
  135. },
  136. //分页改变
  137. changePage() {
  138. this.pagination(this.page.currentPage, this.page.size, this.allData)
  139. },
  140. //发生修改
  141. getChange() {
  142. if (!!this.radio) {
  143. this.$emit("changeInsurer", this.radio)
  144. this.dialog.insurer = false
  145. } else {
  146. this.$message("请选择一个生产厂商")
  147. }
  148. },
  149. //分页事件
  150. pagination(pageNo, pageSize, array) {
  151. let offset = (pageNo - 1) * pageSize;
  152. return offset + pageSize >= array.length
  153. ? array.slice(offset, array.length)
  154. : array.slice(offset, offset + pageSize);
  155. }
  156. },
  157. watch: {
  158. dialog: {
  159. deep: true,
  160. handler: function () {
  161. if (this.dialog.insurer) {
  162. this.getData()
  163. }
  164. }
  165. }
  166. }
  167. };
  168. </script>
  169. <style lang="less">
  170. #firm {
  171. .el-table thead {
  172. tr {
  173. th {
  174. background-color: #f5f7fa;
  175. }
  176. }
  177. }
  178. }
  179. </style>