You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
6.0 KiB

2 years ago
2 years ago
2 years ago
2 years ago
  1. <script>
  2. import BuSelect from "../select/BuSelect.vue";
  3. import {queryProjectList, queryProjectListByPage} from "../../../api/project/project";
  4. import {updateColumnSize} from "../../../api/table";
  5. export default {
  6. name: "projectTable",
  7. components: {BuSelect},
  8. model:{
  9. prop: "visible",
  10. event: "update"
  11. },
  12. props:{
  13. visible: {
  14. type: Boolean,
  15. default: false
  16. },
  17. customerNo:{
  18. type: String,
  19. default: ""
  20. },
  21. height:{
  22. type: Number,
  23. default: 300
  24. },
  25. isPage:{
  26. type: Boolean,
  27. default: false
  28. },
  29. projectNo:{
  30. type: String,
  31. default: ""
  32. },
  33. buId:{
  34. type: Number,
  35. default: ""
  36. },
  37. width:{
  38. type: Number,
  39. default: 800
  40. }
  41. },
  42. data(){
  43. return{
  44. no:1,
  45. size:20,
  46. total:0,
  47. project:{
  48. buId:"",
  49. projectNo:"",
  50. projectDesc:"",
  51. customerNo: "",
  52. customerDesc: ""
  53. },
  54. dataList:[],
  55. queryLoading: false,
  56. }
  57. },
  58. methods:{
  59. handleColumnResize(newWidth, oldWidth, column, event){
  60. let inData= this.columnList.filter(item => item.columnProp === column.property)[0]
  61. inData.columnWidth=newWidth
  62. updateColumnSize(inData).then(({data}) => {
  63. if (data.code === 0) {
  64. console.log("栏位宽度保存成功!")
  65. }
  66. })
  67. },
  68. handleDblClick(row){
  69. this.$emit("dblclick",row)
  70. },
  71. handleSizeChange(val){
  72. this.size = val
  73. this.handleQueryProjectListByPage()
  74. },
  75. handlePageChange(val){
  76. this.no = val
  77. this.handleQueryProjectListByPage()
  78. },
  79. handleQueryProjectListByPage(){
  80. let params = {
  81. ...this.project,
  82. createBy: this.$store.state.user.name,
  83. no:this.no,
  84. size:this.size
  85. }
  86. this.queryLoading = true
  87. queryProjectListByPage(params).then(({data})=>{
  88. if (data && data.code === 0){
  89. this.dataList = data.rows
  90. this.total = data.total
  91. }else {
  92. this.$message.warning(data.msg)
  93. }
  94. this.queryLoading = false
  95. }).catch((error)=>{
  96. this.$message.error(error)
  97. this.queryLoading = false
  98. })
  99. },
  100. handleQueryProjectList(){
  101. let params = {
  102. ...this.project,
  103. createBy: this.$store.state.user.name
  104. }
  105. this.queryLoading = true
  106. queryProjectList(params).then(({data})=>{
  107. if (data && data.code === 0){
  108. this.dataList = data.rows
  109. }else {
  110. this.$message.warning(data.msg)
  111. }
  112. this.queryLoading = false
  113. }).catch((error)=>{
  114. this.$message.error(error)
  115. this.queryLoading = false
  116. })
  117. },
  118. },
  119. created() {
  120. this.project.buId = this.buId
  121. this.project.customerNo = this.customerNo
  122. this.project.projectNo = this.projectNo
  123. },
  124. watch:{
  125. visible(newVal,oldVal){
  126. if (newVal){
  127. if (this.isPage){
  128. this.handleQueryProjectListByPage();
  129. }else {
  130. this.handleQueryProjectList();
  131. }
  132. }
  133. },
  134. customerNo(newVal,oldVal){
  135. this.project.customerNo = newVal
  136. },
  137. projectNo(newVal,oldVal){
  138. this.project.projectNo = newVal
  139. },
  140. buId(newVal,oldVal){
  141. this.project.buId = newVal
  142. },
  143. },
  144. computed:{
  145. open:{
  146. get(){
  147. return this.visible
  148. },
  149. set(val){
  150. this.$emit("update",val)
  151. }
  152. }
  153. }
  154. }
  155. </script>
  156. <template>
  157. <el-dialog :visible.sync="open" v-drag title="项目信息" :close-on-click-modal="false" modal-append-to-body :width="`${width}px`">
  158. <el-form :model="project" label-position="top" label-width="100px">
  159. <el-row :gutter="20">
  160. <el-col :span="6" v-if="!buId">
  161. <el-form-item label="BU">
  162. <bu-select v-model="project.buId" clearable></bu-select>
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="6">
  166. <el-form-item label="项目编号">
  167. <el-input v-model="project.projectNo"></el-input>
  168. </el-form-item>
  169. </el-col>
  170. <el-col :span="6">
  171. <el-form-item label="项目名称">
  172. <el-input v-model="project.projectDesc"></el-input>
  173. </el-form-item>
  174. </el-col>
  175. <el-col :span="24" v-if="!customerNo">
  176. <el-row :gutter="20" >
  177. <el-col :span="6" >
  178. <el-form-item label="客户编码">
  179. <el-input v-model="project.customerNo"></el-input>
  180. </el-form-item>
  181. </el-col>
  182. <el-col :span="6">
  183. <el-form-item label="客户名称">
  184. <el-input v-model="project.customerDesc"></el-input>
  185. </el-form-item>
  186. </el-col>
  187. </el-row>
  188. </el-col>
  189. <el-col :span="4" >
  190. <el-form-item label=" ">
  191. <el-button type="primary" v-if="isPage" @click="handleQueryProjectListByPage">查询</el-button>
  192. <el-button type="primary" v-else @click="handleQueryProjectList">查询</el-button>
  193. </el-form-item>
  194. </el-col>
  195. </el-row>
  196. </el-form>
  197. <el-table :data="dataList" border style="width: 100%" :height="height" v-loading="queryLoading" @row-dblclick="handleDblClick" @header-dragend="handleColumnResize">
  198. <el-table-column label="BU" prop="buDesc"></el-table-column>
  199. <el-table-column label="项目编号" prop="projectNo"></el-table-column>
  200. <el-table-column label="项目名称" prop="projectDesc"></el-table-column>
  201. <el-table-column label="客户编码" prop="customerNo"></el-table-column>
  202. <el-table-column label="客户描述" prop="customerDesc"></el-table-column>
  203. </el-table>
  204. <el-pagination v-if="isPage" @size-change="handleSizeChange"
  205. @current-change="handlePageChange"
  206. :current-page="no"
  207. :page-sizes="[20, 50, 100, 200, 500]"
  208. :page-size="size"
  209. :total="total"
  210. layout="total,sizes, prev, pager, next, jumper">
  211. </el-pagination>
  212. </el-dialog>
  213. </template>
  214. <style scoped>
  215. </style>