commonpopup.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class="pop-container">
  3. <uni-popup ref="popup" type="dialog" >
  4. <uni-popup-dialog
  5. :title="title"
  6. message=""
  7. :duration="2000"
  8. :before-close="true"
  9. @close="handleCancel"
  10. @confirm="handleOk">
  11. <view class="dialog-content">
  12. <view class="header-container">
  13. <uni-row class="demo-uni-row">
  14. <uni-col :span="5" style="padding-left: 10px;text-align: center" >
  15. <view class="gjz-title">关键字</view>
  16. </uni-col>
  17. <uni-col :span="19">
  18. <uni-search-bar
  19. v-model="keyWord"
  20. @input="input"
  21. @cancel="cancel"
  22. @clear="clear"
  23. cancelButton="none"
  24. />
  25. </uni-col>
  26. </uni-row>
  27. <uni-row class="demo-uni-row">
  28. <uni-col :span="24" style="text-align: center;">
  29. <button class="mini-btn" type="primary" size="mini" @click="search">查询</button>
  30. </uni-col>
  31. </uni-row>
  32. </view>
  33. <view style="height: 200px">
  34. <zb-table
  35. ref="zbTable"
  36. :show-header="true"
  37. :stripe="false"
  38. :columns="column"
  39. :data="data"
  40. :highlight="true"
  41. @currentChange="currentChange"
  42. :border="true"
  43. >
  44. </zb-table>
  45. </view>
  46. </view>
  47. <!-- <view slot="footer">
  48. <button type="primary" @click="handleOk">确定</button>
  49. <button @click="handleCancel">取消</button>
  50. </view> -->
  51. </uni-popup-dialog>
  52. </uni-popup>
  53. </view>
  54. </template>
  55. <script>
  56. import { getDicts } from "@/api/system/dict/data"; // 字典
  57. import { reserveIssue,reserveIssue2 } from '@/api/mes/pro.js'
  58. export default {
  59. props: {
  60. title: {
  61. type: String,
  62. required: true
  63. },
  64. idxFlag:{
  65. type: String,
  66. required: true
  67. },
  68. formData:{
  69. type: Object,
  70. require: true
  71. }
  72. },
  73. mounted() {
  74. },
  75. created: function(option) {
  76. },
  77. data() {
  78. return {
  79. currentFlag: '',
  80. keyWord: '', // 输入查询的值
  81. column: [], // 表头数据
  82. data: [], // 表体数据
  83. data2: [], // 表体数据2
  84. currentSelectData: {}, //当前选中数据行
  85. };
  86. },
  87. methods:{
  88. handleOk() {
  89. let returnData = {
  90. currentFlag: this.currentFlag,
  91. selectData: this.currentSelectData
  92. }
  93. this.$emit("sendData", returnData);
  94. // 点击确定按钮的处理逻辑
  95. this.currentSelectData = {}
  96. this.$refs.popup.close()
  97. },
  98. handleCancel() {
  99. // 点击取消按钮的处理逻辑
  100. this.$refs.popup.close()
  101. },
  102. showPopup() {
  103. // 传递的哪个跳转标志位
  104. this.currentFlag = this.idxFlag;
  105. let that = this;
  106. let cFlag = that.idxFlag;
  107. switch (cFlag){
  108. case "lld": // 领料单
  109. that.column = [
  110. { name: 'batchCode', label:'批次号', width:90, align:'center', emptyString:'--'},
  111. { name: 'itemCode', label: '产品物料编码', width:150, align:'center', emptyString:'--'},
  112. { name: 'itemName', label: '产品物料名称', width:150, align:'center', emptyString:'--'},
  113. { name: 'warehouseName', label: '仓库名称', width:90, align:'center', emptyString:'--'},
  114. { name: 'quantityIssued', label: '领料量', width:90, align:'center', emptyString:'--'},
  115. ];
  116. that.getReserveIssue();
  117. break;
  118. default:
  119. break;
  120. }
  121. },
  122. hidePopup() {
  123. this.$refs.popup.close();
  124. },
  125. // 单选当前行
  126. currentChange(row,index){
  127. this.currentSelectData = row;
  128. },
  129. // searchBar
  130. input(value) {// uniSearchBar 的 value 改变时触发事件,返回参数为uniSearchBar的 value e=value
  131. this.keyWord = value;
  132. },
  133. clear(res) {
  134. this.keyWord = "";
  135. },
  136. cancel(res) {
  137. this.keyWord = "";
  138. },
  139. // 查询按钮点击事件
  140. search(){
  141. let that = this;
  142. let cFlag = that.idxFlag;
  143. switch (cFlag){
  144. case "lld": //单据
  145. this.getReserveIssue();
  146. break;
  147. default:
  148. break;
  149. }
  150. },
  151. async getReserveIssue(){
  152. let params = {
  153. workstationId:this.formData.workstationId,
  154. params: {
  155. "keyWord":this.keyWord
  156. },
  157. }
  158. await reserveIssue(params).then(res => {
  159. if(res.code === 200){
  160. this.data = res.data.map(item => ({
  161. sourceDocId: item.id,
  162. sourceLineId: item.id,
  163. batchCode: item.batch,
  164. itemCode: item.materialCode,
  165. itemName: item.materialName,
  166. specification: item.materialSpecification,
  167. warehouseName: item.warehouseName,
  168. quantityIssued: item.stockQty,
  169. unitOfMeasure: item.unitCode
  170. }));
  171. this.$refs.popup.open();
  172. }
  173. });
  174. let params2 = {
  175. workorderId:this.formData.workorderId,
  176. params: {
  177. "keyWord":this.keyWord
  178. },
  179. }
  180. await reserveIssue2(params2).then(res => {
  181. if(res.code === 200){
  182. this.data2 = res.data.flatMap(item =>
  183. item.wmsStockOutsList.map(subItem => ({
  184. sourceDocId: item.id,
  185. sourceLineId: subItem.id,
  186. batchCode: subItem.batch,
  187. itemCode: subItem.materialCode,
  188. itemName: subItem.materialName,
  189. specification: subItem.materialSpecification,
  190. warehouseName: item.warehouseName,
  191. quantityIssued: subItem.stockQty,
  192. unitOfMeasure: subItem.unitCode
  193. }))
  194. );
  195. this.$refs.popup.open();
  196. }
  197. });
  198. //合并两个接口数据
  199. this.data = this.data.concat(this.data2);
  200. },
  201. },
  202. }
  203. </script>
  204. <style>
  205. @import "@/static/scss/commonpopup.css"
  206. </style>