maintainerDialog.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <!--
  2. maintenance 选择供应商
  3. -->
  4. <template>
  5. <el-dialog title="选择维修商" :visible.sync="dialog.maintainer" 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 class="data-table" border 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="contacts[0].name" label="联系人"></el-table-column>
  29. <el-table-column header-align='center' prop="contacts[0].phone" label="联系电话"></el-table-column>
  30. <el-table-column header-align='center' prop="contacts[0].fax" label="传真"></el-table-column>
  31. <el-table-column header-align='center' prop="contacts[0].email" label="电子邮件"></el-table-column>
  32. </el-table>
  33. </el-radio-group>
  34. <div class="right" style="background: #fff;">
  35. <p style="height:40px;line-height:40px;text-align:center;color:#9E9E9E; float: left;">
  36. 找不到想要的型号? 赶快去
  37. <i style="color:#46B0FF;cursor: pointer;">厂家库</i>维护吧
  38. </p>
  39. <my-pagination :page="page" @change="changePage" style="margin-top:10px;"></my-pagination>
  40. </div>
  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/ledger/lib/myPagination";
  53. import { mapGetters } from "vuex";
  54. import { getLib } from "@/api/scan/request"
  55. import tools from "@/utils/scan/tools"
  56. export default {
  57. components: {
  58. myPagination
  59. },
  60. props: {
  61. dialog: {
  62. type: Object,
  63. default: function () {
  64. return {
  65. maintainer: true
  66. };
  67. }
  68. }
  69. },
  70. computed: {
  71. ...mapGetters("layout", ["projectId", "secret", "userId"]),
  72. },
  73. data() {
  74. return {
  75. search: "", //搜索文案
  76. radio: "",
  77. tableData: [],
  78. page: {
  79. size: 50,
  80. sizes: [10, 30, 50, 100, 150, 200],
  81. total: 0,
  82. currentPage: 1
  83. }
  84. };
  85. },
  86. created() {
  87. // this.getData()
  88. },
  89. mounted() { },
  90. methods: {
  91. //过滤
  92. filterSearch() {
  93. this.tableData = this.allData.map(item => {
  94. if (item.name.indexOf(this.search) != -1) {
  95. return item
  96. } else {
  97. return undefined
  98. }
  99. }).filter(cb => cb)
  100. },
  101. getData() {
  102. this.page = {
  103. size: 50,
  104. sizes: [10, 30, 50, 100, 150, 200],
  105. total: 0,
  106. currentPage: 1
  107. }
  108. getLib({ "type": ["maintenance"] }).then(res => {
  109. if (res.data.result == "success") {
  110. this.allData = tools.deepCopy(res.data.content.maintenance)
  111. this.tableData = this.pagination(this.page.currentPage, this.page.size, this.allData)
  112. this.page.total = this.allData.length
  113. } else {
  114. this.$message.error("请求失败:" + res.data.resultMsg)
  115. }
  116. })
  117. },
  118. //分页改变
  119. changePage() {
  120. this.pagination(this.page.currentPage, this.page.size, this.allData)
  121. },
  122. //发生修改
  123. getChange() {
  124. if (!!this.radio) {
  125. console.log(this.radio, "radio")
  126. this.$emit("changeMaintainer", this.radio)
  127. this.dialog.maintainer = false
  128. } else {
  129. this.$message("请选择一个生产厂商")
  130. }
  131. },
  132. //分页事件
  133. pagination(pageNo, pageSize, array) {
  134. let offset = (pageNo - 1) * pageSize;
  135. return offset + pageSize >= array.length
  136. ? array.slice(offset, array.length)
  137. : array.slice(offset, offset + pageSize);
  138. }
  139. },
  140. watch: {
  141. dialog: {
  142. deep: true,
  143. handler: function () {
  144. if (this.dialog.maintainer) {
  145. this.getData()
  146. }
  147. }
  148. }
  149. }
  150. };
  151. </script>
  152. <style lang="less">
  153. #firm {
  154. .el-table thead {
  155. tr {
  156. th {
  157. background-color: #f5f7fa;
  158. }
  159. }
  160. }
  161. }
  162. </style>