index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" label-width="68px">
  4. <el-row >
  5. <el-col :span="18">
  6. <el-form-item label="物料">
  7. <el-input v-model="queryParams.params.materialNameOrCode"></el-input>
  8. </el-form-item>
  9. <el-form-item label="客户">
  10. <el-input v-model="queryParams.params.customerNameOrCode"></el-input>
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="6">
  14. <el-form-item style="float:right">
  15. <el-button type="primary" icon="el-icon-search" size="mini" @click="btnQuery">搜索</el-button>
  16. <el-button icon="el-icon-refresh" size="mini" @click="btnResetQuery">重置</el-button>
  17. </el-form-item>
  18. </el-col>
  19. </el-row>
  20. </el-form>
  21. <div style="float:right">
  22. <el-button type="primary" size="mini" @click="btnAdd">新增</el-button>
  23. </div>
  24. <el-table
  25. size="mini"
  26. v-loading="loading"
  27. :data="list"
  28. height="500px"
  29. >
  30. <el-table-column show-overflow-tooltip min-width="200" label="序号" align="center" prop="id" />
  31. <el-table-column show-overflow-tooltip min-width="200" label="物料" align="center" prop="materialName" />
  32. <el-table-column show-overflow-tooltip min-width="200" label="物料编码" align="center" prop="materialCode" />
  33. <el-table-column show-overflow-tooltip min-width="200" label="客户" align="center" prop="customerName" />
  34. <el-table-column show-overflow-tooltip min-width="200" label="客户编码" align="center" prop="customerCode" />
  35. <el-table-column
  36. width="250"
  37. label="操作"
  38. fixed="right"
  39. align="center"
  40. class-name="small-padding fixed-width"
  41. >
  42. <template slot-scope="scope">
  43. <el-button size="mini" type="text" @click="btnUpdate(scope.row)">修改</el-button>
  44. <el-button size="mini" type="text" @click="btnDelete(scope.row)">删除</el-button>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. <div class="paginationClass">
  49. <pagination
  50. v-show="total > 0"
  51. :total="total"
  52. :page.sync="queryParams.pageNum"
  53. :limit.sync="queryParams.pageSize"
  54. @pagination="getList"
  55. />
  56. </div>
  57. <!-- 添加或修改任务对话框 -->
  58. <el-dialog
  59. :title="title"
  60. :visible.sync="open"
  61. width="500px"
  62. append-to-body
  63. :close-on-click-modal="false"
  64. :show-close="false"
  65. >
  66. <el-form
  67. size="mini"
  68. ref="form"
  69. :model="form"
  70. label-width="80px"
  71. :rules="formRules"
  72. >
  73. <el-form-item label="物料" prop="materialName">
  74. <DrPopoverSelectV2
  75. size="mini"
  76. v-model="form.materialName"
  77. valueKey= "name"
  78. referName="MATERIAL_PARAM"
  79. :dataMapping="{
  80. material: 'id',
  81. materialCode: 'code',
  82. }"
  83. :source.sync="form"
  84. >
  85. </DrPopoverSelectV2>
  86. </el-form-item>
  87. <el-form-item label="客户" prop="customerName">
  88. <DrPopoverSelectV2
  89. size="mini"
  90. v-model="form.customerName"
  91. valueKey= "name"
  92. referName="CUSTOMER_PARAM"
  93. :dataMapping="{
  94. customer: 'id',
  95. customerCode: 'code',
  96. }"
  97. :source.sync="form"
  98. >
  99. </DrPopoverSelectV2>
  100. </el-form-item>
  101. </el-form>
  102. <div slot="footer">
  103. <el-button
  104. size="mini"
  105. type="primary"
  106. @click="submitForm"
  107. >确 定</el-button
  108. >
  109. <el-button size="mini" @click="cancel">取 消</el-button>
  110. </div>
  111. </el-dialog>
  112. </div>
  113. </template>
  114. <script>
  115. import {list,detail,insert,update,del} from '@/api/purchase/ownershipLot.js'
  116. export default {
  117. data() {
  118. return {
  119. // 遮罩层
  120. loading: true,
  121. // 选中数组
  122. ids: [],
  123. // 非单个禁用
  124. single: true,
  125. // 非多个禁用
  126. multiple: true,
  127. // 总条数
  128. total: 0,
  129. // 列表数据
  130. list: [],
  131. // 弹出层标题
  132. title: "",
  133. // 是否显示弹出层
  134. open: false,
  135. // 查询参数
  136. queryParams: {
  137. pageNum: 1,
  138. pageSize: 10,
  139. code: null,
  140. params:{
  141. materialNameOrCode: null,
  142. customerNameOrCode: null,
  143. },
  144. },
  145. // 表单参数
  146. form: {
  147. },
  148. //校验规则
  149. formRules:{
  150. materialName: [
  151. { required: true, message: "物料不能为空", trigger: "blur" },
  152. ],
  153. customerName: [
  154. { required: true, message: "客户不能为空", trigger: "blur" },
  155. ],
  156. },
  157. };
  158. },
  159. async created() {
  160. await this.getList();
  161. },
  162. methods: {
  163. /** 查询任务列表 */
  164. getList() {
  165. this.loading = true;
  166. list(this.queryParams).then(response => {
  167. this.list = response.rows;
  168. this.total = response.total;
  169. this.loading = false;
  170. });
  171. },
  172. // 取消按钮
  173. cancel() {
  174. this.form = {};
  175. this.open = false;
  176. },
  177. /** 搜索按钮操作 */
  178. btnQuery() {
  179. this.queryParams.pageNum = 1;
  180. this.getList();
  181. },
  182. /** 重置按钮操作 */
  183. btnResetQuery() {
  184. this.queryParams = {
  185. pageNum: 1,
  186. pageSize: 10,
  187. code: null,
  188. params:{
  189. materialNameOrCode: null,
  190. customerNameOrCode: null,
  191. },
  192. };
  193. this.btnQuery();
  194. },
  195. /** 修改按钮操作 */
  196. btnUpdate(row) {
  197. const id = row.id;
  198. detail(id).then(response => {
  199. this.form = {...this.form,...response.data};
  200. this.open = true;
  201. this.title = "修改";
  202. });
  203. },
  204. /** 提交表单 */
  205. submitForm() {
  206. this.$refs["form"].validate(valid => {
  207. if (valid) {
  208. if(this.form.id){
  209. update(this.form).then(response => {
  210. this.$modal.msgSuccess("修改成功");
  211. this.open = false;
  212. this.form = {};
  213. this.getList();
  214. });
  215. }else{
  216. insert(this.form).then(response => {
  217. this.$modal.msgSuccess("新增成功");
  218. this.open = false;
  219. this.form = {};
  220. this.getList();
  221. });
  222. }
  223. }
  224. });
  225. },
  226. btnAdd(){
  227. this.open = true;
  228. this.title = "新增";
  229. },
  230. btnDelete(row){
  231. this.$modal.confirm('是否确认删除"' + row.materialName + "+" + row.customerName + '"数据?').then(function() {
  232. return del(row.id);
  233. }).then(() => {
  234. this.getList();
  235. this.$modal.msgSuccess("删除成功");
  236. }).catch(() => {});
  237. }
  238. }
  239. };
  240. </script>
  241. <style lang="scss" scoped>
  242. .btn_grooup {
  243. margin-bottom: 10px;
  244. display: flex;
  245. justify-content: flex-end;
  246. }
  247. .paginationClass {
  248. z-index: 500;
  249. position: fixed;
  250. bottom: 10px;
  251. right: 10px;
  252. width: 100%;
  253. line-height: var(--footer-height);
  254. color: #fff;
  255. }
  256. </style>