supplyDialog.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <!--
  2. supply 供应合同选择
  3. -->
  4. <template>
  5. <el-dialog title="选择供应合同" :visible.sync="dialog.supply" width="600px">
  6. <el-tabs type="border-card">
  7. <el-tab-pane>
  8. <span slot="label">选择供应合同</span>
  9. <div id="firm">
  10. <el-radio-group v-model="radio" style="width:100%;">
  11. <el-table :data="tableData" style="width: 100%" height="300px">
  12. <el-table-column label="合同编号">
  13. <template slot-scope="scope">
  14. <el-radio v-model="radio" :label="scope.row">{{scope.row}}</el-radio>
  15. </template>
  16. </el-table-column>
  17. </el-table>
  18. </el-radio-group>
  19. <div class="right" style="background: #fff;">
  20. <p style="height:40px;line-height:40px;text-align:center;color:#9E9E9E; float: left;">
  21. 找不到想要的型号? 赶快去
  22. <i style="color:#46B0FF;cursor: pointer;">厂家库</i>维护吧
  23. </p>
  24. <my-pagination :page="page" @change="pageChange" style="margin-top:10px;"></my-pagination>
  25. </div>
  26. <div class="footer">
  27. <el-button
  28. type="primary"
  29. style="display:block;margin: 10px auto 0;"
  30. @click="setData"
  31. >确 定</el-button>
  32. </div>
  33. </div>
  34. </el-tab-pane>
  35. <el-tab-pane>
  36. <span slot="label">新建供应合同</span>
  37. <el-form label-width="80px" :rules="rules" :model="formData" ref="ruleForm">
  38. <el-form-item label="供应合同" prop="name">
  39. <el-input v-model="formData.name"></el-input>
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
  43. <el-button @click="resetForm('ruleForm')">重置</el-button>
  44. </el-form-item>
  45. </el-form>
  46. </el-tab-pane>
  47. </el-tabs>
  48. </el-dialog>
  49. </template>
  50. <script>
  51. import myPagination from "@/components/ledger/lib/myPagination";
  52. import { getListForSupplier } from "@/api/scan/request"
  53. import tools from "@/utils/scan/tools"
  54. import { mapGetters, mapActions } from "vuex";
  55. export default {
  56. components: {
  57. myPagination
  58. },
  59. props: {
  60. dialog: {
  61. type: Object,
  62. default: function () {
  63. return {
  64. supply: true
  65. };
  66. }
  67. },
  68. id: {
  69. type: [Number, String],
  70. default: 0
  71. }
  72. },
  73. computed: {
  74. ...mapGetters("layout", ["projectId", "secret", "userId"])
  75. },
  76. data() {
  77. return {
  78. search: "", //搜索文案
  79. radio: "",
  80. formData: {
  81. name: ""
  82. },
  83. rules: {
  84. name: { required: true, message: '请输入保单号', trigger: 'blur' },
  85. },
  86. tableData: [],
  87. page: {
  88. size: 50,
  89. sizes: [10, 30, 50, 100, 150, 200],
  90. total: 0,
  91. currentPage: 1
  92. },
  93. allData: []
  94. };
  95. },
  96. created() { },
  97. mounted() { },
  98. methods: {
  99. submitForm(formName) {
  100. let _this = this
  101. this.$refs[formName].validate((valid) => {
  102. if (valid) {
  103. _this.$emit("change", this.formData.name)
  104. this.dialog.supply = false
  105. } else {
  106. return false;
  107. }
  108. });
  109. },
  110. resetForm() {
  111. this.$refs.ruleForm.resetFields();
  112. },
  113. setData() {
  114. this.$emit("change", this.radio)
  115. this.dialog.supply = false
  116. },
  117. //获取列表
  118. getList() {
  119. this.radio = ""
  120. let _this = this
  121. this.page = {
  122. size: 50,
  123. sizes: [10, 30, 50, 100, 150, 200],
  124. total: 0,
  125. currentPage: 1
  126. }
  127. if (!!this.id) {
  128. let param = {
  129. data: {
  130. projectId: this.projectId,
  131. venderId: this.id
  132. },
  133. ProjId: this.projectId,
  134. secret: this.secret,
  135. }
  136. getListForSupplier(param, res => {
  137. _this.$refs.ruleForm.resetFields()
  138. _this.allData = res.contractId || []
  139. _this.page.total = _this.allData.length
  140. //分页
  141. _this.pageChange()
  142. })
  143. }
  144. },
  145. pageChange() {
  146. this.tableData = tools.pagination(this.page.currentPage, this.page.size, this.allData)
  147. }
  148. },
  149. watch: {
  150. dialog: {
  151. deep: true,
  152. handler: function (val) {
  153. if (this.dialog.supply) {
  154. this.getList()
  155. }
  156. }
  157. }
  158. }
  159. };
  160. </script>