choosematerial.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <div>
  3. <el-button type="primary" size="mini" @click="openDialog">筛选</el-button>
  4. <el-dialog title="客户历史销售物料查询" :visible.sync="open" :before-close="useClose">
  5. <el-form size="mini" label-width="120px" >
  6. <el-row :gutter="10">
  7. <el-col :span="1.5">
  8. <el-form-item label="物料编码">
  9. <el-input
  10. v-model="queryParams.code"
  11. clearable
  12. style="width: 200px"
  13. />
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="1.5">
  17. <el-form-item label="物料名称">
  18. <el-input
  19. v-model="queryParams.name"
  20. clearable
  21. style="width: 200px"
  22. />
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="1.5">
  26. <el-form-item>
  27. <el-button type="primary" icon="el-icon-search" plain @click="useSearch">搜索</el-button>
  28. <el-button icon="el-icon-refresh" plain @click="useReset">重置</el-button>
  29. </el-form-item>
  30. </el-col>
  31. </el-row>
  32. </el-form>
  33. <el-table :data="tableData" size="mini" @row-dblclick="useDoubleClick" @selection-change="useSelectChange" v-loading="loading" height="450px">
  34. <el-table-column type="selection" width="55"> </el-table-column>
  35. <el-table-column show-overflow-tooltip label="编码" align="center" width="150" prop="code"/>
  36. <el-table-column show-overflow-tooltip label="名称" align="center" width="200" prop="name"/>
  37. <el-table-column show-overflow-tooltip label="物料分类" align="center" width="150" prop="fourClass" />
  38. <el-table-column show-overflow-tooltip label="单位" align="center" width="100" prop="unitIdName"/>
  39. <el-table-column show-overflow-tooltip label="规格" align="center" width="200" prop="specification" />
  40. <el-table-column show-overflow-tooltip label="生产厂家" align="center" width="200" prop="manufacturersMaterialName" />
  41. </el-table>
  42. <el-pagination
  43. background
  44. @size-change="useChangePageSize"
  45. @current-change="useCurrentChange"
  46. :current-page="queryParams.pageNum"
  47. :page-sizes="[10, 15, 20]"
  48. :page-size="100"
  49. layout="total, sizes, prev, pager, next, jumper"
  50. :total=total>
  51. </el-pagination>
  52. <el-card>
  53. <div class="btn_group">
  54. <el-col :span="1.5" style="margin: 0 10px;">
  55. <el-button type="primary" size="mini" plain @click="selectAll">全选</el-button>
  56. </el-col>
  57. <el-col :span="1.5" style="margin: 0 10px;">
  58. <el-button type="primary" size="mini" plain @click="useConfirm">确认</el-button>
  59. </el-col>
  60. </div>
  61. </el-card>
  62. </el-dialog>
  63. </div>
  64. </template>
  65. <script>
  66. import {getSaleMaterialList} from "@/api/business/spd/fillin/dailysale_quantity_assess";
  67. import { saveItems,selectAllSaleMat } from "@/api/business/spd/fillin/dailysale_quantity_assess_item";
  68. export default {
  69. name: "dailysaleQuantityAssessDetailChoosematerial",
  70. props: ["form"],
  71. data() {
  72. return {
  73. loading: false,
  74. //是否打开弹窗
  75. open:false,
  76. //搜索框参数
  77. queryParams:{
  78. customer: null,
  79. materialCode: null,
  80. materialName: null,
  81. pageNum:1,
  82. pageSize:10,
  83. },
  84. //总条数
  85. total: 0,
  86. //列表数据
  87. tableData:[],
  88. //选择的数据
  89. selectionData:[],
  90. };
  91. },
  92. methods: {
  93. //打开弹窗
  94. openDialog(){
  95. if(!this.form.customer){
  96. this.$modal.msgError("请选择客户!");
  97. return;
  98. }
  99. this.open = true;
  100. this.getList();
  101. },
  102. //关闭弹窗
  103. useClose(done){
  104. this.selectionData = [];
  105. this.queryParams = {
  106. customer: null,
  107. materialCode: null,
  108. materialName: null,
  109. pageNum:1,
  110. pageSize:10,
  111. }
  112. done();
  113. },
  114. //获取列表数据
  115. async getList() {
  116. try {
  117. this.loading = true;
  118. this.queryParams.customer = this.form.customer;
  119. const { code, rows, total } = await getSaleMaterialList(this.queryParams);
  120. if (code === 200) {
  121. this.tableData = rows;
  122. this.total = total;
  123. }
  124. } catch (err) {
  125. // catch
  126. console.error(err);
  127. } finally {
  128. // finally
  129. this.loading = false;
  130. }
  131. },
  132. //多选
  133. useSelectChange(selection){
  134. this.selectionData = selection;
  135. },
  136. //全选
  137. selectAll(){
  138. this.$modal.confirm('您确定要全选销售给当前客户的所有物料吗').then(() => {
  139. selectAllSaleMat(this.form.id).then(res => {
  140. if(res.code == '200'){
  141. this.$modal.msgSuccess("全选成功");
  142. this.$emit("useReset");
  143. this.open = false;
  144. }else{
  145. this.$modal.msgError("全选失败,请联系管理员!");
  146. }
  147. })
  148. }).catch(() => {})
  149. },
  150. //确认多选
  151. async useConfirm(){
  152. if(this.selectionData.length < 1){
  153. this.$modal.msgError("未选择数据!");
  154. return;
  155. }
  156. const arr = [];
  157. for(let i in this.selectionData){
  158. arr.push({
  159. dailysaleQuantityAssessId:this.form.id,
  160. oneClassName:this.selectionData[i].oneClass,
  161. twoClassName:this.selectionData[i].twoClass,
  162. material:this.selectionData[i].id,
  163. materialCode:this.selectionData[i].code,
  164. materialName:this.selectionData[i].name,
  165. unitName:this.selectionData[i].unitIdName,
  166. price:this.selectionData[i].price,
  167. });
  168. }
  169. let res = await saveItems(arr);
  170. if(res.code == '200'){
  171. this.$modal.msgSuccess("添加成功");
  172. this.$emit("useReset");
  173. this.open = false;
  174. }else{
  175. this.$modal.msgError("保存失败,请联系管理员!");
  176. }
  177. },
  178. //双击选择
  179. async useDoubleClick(row){
  180. const arr = [];
  181. arr.push({
  182. dailysaleQuantityAssessId:this.form.id,
  183. oneClassName:row.oneClass,
  184. twoClassName:row.twoClass,
  185. material:row.id,
  186. materialCode:row.code,
  187. materialName:row.name,
  188. unitName:row.unitIdName,
  189. price:row.price,
  190. });
  191. let res = await saveItems(arr);
  192. if(res.code == '200'){
  193. this.$modal.msgSuccess("添加成功");
  194. this.$emit("useReset");
  195. this.open = false;
  196. }else{
  197. this.$modal.msgError("保存失败,请联系管理员!");
  198. }
  199. },
  200. //搜索
  201. useSearch(){
  202. this.getList();
  203. },
  204. //重置
  205. useReset(){
  206. this.queryParams = {
  207. customer: null,
  208. materialCode: null,
  209. materialName: null,
  210. pageNum:1,
  211. pageSize:10,
  212. }
  213. this.getList();
  214. },
  215. //改变一页显示条数
  216. useChangePageSize(val){
  217. this.queryParams.pageSize = val
  218. this.getList()
  219. },
  220. //翻页
  221. useCurrentChange(val){
  222. this.queryParams.pageNum = val
  223. this.getList()
  224. },
  225. },
  226. };
  227. </script>
  228. <style scoped lang="scss">
  229. .btn_group {
  230. width: 100%;
  231. margin: 20px 0;
  232. display: flex;
  233. justify-content: right;
  234. }
  235. .el-pagination {
  236. margin-top: 10px;
  237. text-align: right;
  238. }
  239. </style>