dispatch-add.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div>
  3. <div class="my-title">{{ !id ? '新增' : display ? '详情' : '修改' }}</div>
  4. <!-- 表单 -->
  5. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
  6. <el-row class="my-row">
  7. <el-col :span="8">
  8. <el-form-item label="项目号" prop="contractId">
  9. <contract-component v-model="dataForm.contractId" :contract-id="dataForm.contractId" />
  10. </el-form-item>
  11. </el-col>
  12. </el-row>
  13. <el-row>
  14. <div class="title">发货时间</div>
  15. <el-table :data="dataForm.list" border style="width: 100%;">
  16. <el-table-column label="序号" type="index" width="50" align="center">
  17. </el-table-column>
  18. <el-table-column prop="productName" header-align="center" align="center" label="名称">
  19. </el-table-column>
  20. <el-table-column prop="productSpec" header-align="center" align="center" label="型号/规格">
  21. </el-table-column>
  22. <el-table-column prop="deliverCode" header-align="center" align="center" label="编号">
  23. </el-table-column>
  24. <el-table-column prop="batchNumber" header-align="center" align="center" label="批次号">
  25. </el-table-column>
  26. <el-table-column prop="deliverCnt" header-align="center" align="center" label="数量">
  27. </el-table-column>
  28. <el-table-column prop="price" header-align="center" align="center" label="单价">
  29. </el-table-column>
  30. <el-table-column prop="amount" header-align="center" align="center" label="总价">
  31. </el-table-column>
  32. <el-table-column prop="notes" header-align="center" align="center" label="备注">
  33. </el-table-column>
  34. <el-table-column fixed="right" header-align="center" align="center" width="80" label="操作">
  35. <template slot-scope="scope">
  36. <el-button style="color: red" type="text" size="small" @click="removeItem(scope.$index)">移除</el-button>
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. <el-row style="text-align: center; margin-top: 10px;">
  41. <el-button v-show="!display" type="primary" icon="el-icon-plus" @click="addDeliverList"></el-button>
  42. </el-row>
  43. </el-row>
  44. </el-form>
  45. <span slot="footer" class="dialog-footer">
  46. <el-button @click="onChose">取消</el-button>
  47. <el-button v-if="!display" type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
  48. </span>
  49. <el-dialog title="添加" width="70%" :close-on-click-modal="false" :visible.sync="addItemVisible">
  50. <div>
  51. <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
  52. <el-form-item label="名称/图号">
  53. <el-input v-model="dataForm.materialName" placeholder="名称" clearable />
  54. </el-form-item>
  55. <el-form-item>
  56. <el-button @click="search()">查询</el-button>
  57. </el-form-item>
  58. </el-form>
  59. <el-table border :data="whMaterialRecords" @selection-change="itemSelectionChangeHandle">
  60. <el-table-column type="selection"></el-table-column>
  61. <el-table-column label="序号" type="index" width="50" align="center">
  62. </el-table-column>
  63. <el-table-column prop="orderName" header-align="center" align="center" min-width="100"
  64. :show-tooltip-when-overflow="true" label="名称">
  65. </el-table-column>
  66. <el-table-column prop="mapNumber" header-align="center" align="center" min-width="100"
  67. :show-tooltip-when-overflow="true" label="图号">
  68. </el-table-column>
  69. <el-table-column prop="specifications" header-align="center" align="center" min-width="100"
  70. :show-tooltip-when-overflow="true" label="规格">
  71. </el-table-column>
  72. <el-table-column prop="cnt" header-align="center" align="center" min-width="50"
  73. :show-tooltip-when-overflow="true" label="数量">
  74. </el-table-column>
  75. <el-table-column prop="cnt2" header-align="center" align="center" min-width="80"
  76. :show-tooltip-when-overflow="true" label="发货数量">
  77. <template slot-scope="scope">
  78. <el-input-number v-model="scope.row.cnt2" size="mini"></el-input-number>
  79. </template>
  80. </el-table-column>
  81. <el-table-column prop="notes" header-align="center" align="center" min-width="100"
  82. :show-tooltip-when-overflow="true" label="备注">
  83. <template slot-scope="scope">
  84. <el-input v-model="scope.row.notes"></el-input>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. </div>
  89. <span slot="footer">
  90. <el-button @click="addItemVisible = false">取 消</el-button>
  91. <el-button type="primary" @click="addItemSubmit">确 定</el-button>
  92. </span>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script>
  97. import ContractComponent from '../common/contract-component'
  98. export default {
  99. name: 'dispatch-add',
  100. components: { ContractComponent },
  101. computed: {},
  102. data() {
  103. return {
  104. productListVisible: false,
  105. drawListVisible: false,
  106. materialCompVisible: false,
  107. visible: false,
  108. display: false,
  109. addItemVisible: false,
  110. listingList: [],
  111. dataList: [],
  112. id: 0,
  113. whMaterialRecords: [],
  114. dataForm: {
  115. list: []
  116. },
  117. selectedItems: [],
  118. dataRule: {
  119. contractId: [{ required: true, message: '请选择', trigger: 'blur' }],
  120. },
  121. }
  122. },
  123. methods: {
  124. onChose() {
  125. this.$emit('onChose')
  126. },
  127. async init(id, display) {
  128. },
  129. uploadSuccess(fileList) {
  130. this.fileList = fileList
  131. },
  132. // 添加组合物料
  133. addProduct() {
  134. this.productListVisible = true
  135. this.$nextTick(() => {
  136. this.$refs.productList.init()
  137. })
  138. },
  139. addProductItems(items) {
  140. // this.productDetails = []
  141. items.forEach((item) => {
  142. this.addProductItem(item)
  143. })
  144. },
  145. addProductItem(item) {
  146. let productId = item.productId
  147. if (!this.productDetails.some(item => item.productId === productId)) {
  148. this.productDetails.push({
  149. ...item
  150. })
  151. }
  152. },
  153. deleteProductHandle(productId) {
  154. this.productDetails.splice(this.productDetails.findIndex((item) => item.productId === productId), 1)
  155. },
  156. validateField(type) {
  157. this.$refs.dataForm.validateField(type)
  158. },
  159. // 表单提交
  160. dataFormSubmit() {
  161. this.$refs['dataForm'].validate((valid) => {
  162. if (valid) {
  163. this.$http({
  164. url: this.$http.adornUrl(`/biz-service/deliver/save`),
  165. method: 'post',
  166. data: this.$http.adornData(this.dataForm.list)
  167. }).then(({ data }) => {
  168. if (data && data.code === '200') {
  169. this.$message({
  170. message: '操作成功',
  171. type: 'success',
  172. duration: 1500,
  173. onClose: () => {
  174. this.onChose()
  175. this.$emit('refreshDataList')
  176. }
  177. })
  178. } else {
  179. this.$message.error(data.msg)
  180. }
  181. })
  182. } else {
  183. // this.$message.error('请检查输入参数')
  184. }
  185. })
  186. },
  187. // 添加发货清单
  188. addDeliverList() {
  189. this.addItemVisible = true
  190. this.search()
  191. },
  192. removeItem(index) {
  193. this.dataForm.list.splice(index, 1)
  194. },
  195. search() {
  196. this.$http({
  197. url: this.$http.adornUrl(`/biz-service/stock-mg-ctl/list`),
  198. method: 'get',
  199. params: this.$http.adornParams({
  200. 'current': 1,
  201. 'size': 10,
  202. 'materialName': this.dataForm.materialName
  203. })
  204. }).then(({ data }) => {
  205. if (data && data.code === '200') {
  206. this.whMaterialRecords = data.data.records
  207. this.whMaterialRecords.forEach(item => {
  208. item.cnt2 = 0;
  209. });
  210. } else {
  211. this.$message.error(data.msg)
  212. }
  213. })
  214. },
  215. // 选择数量变化时
  216. itemSelectionChangeHandle(val) {
  217. this.selectedItems = val
  218. },
  219. addItemSubmit() {
  220. // 判断是否有选择数据
  221. if (this.selectedItems.length === 0) {
  222. this.$message.error("请勾选数据")
  223. return
  224. }
  225. for (let index = 0; index < this.selectedItems.length; index++) {
  226. const element = this.selectedItems[index];
  227. if (element.cnt2 <= 0) {
  228. this.$message.error("第" + (index + 1) + "条发货数量不能小于等于0")
  229. return
  230. }
  231. }
  232. let data = this.selectedItems.map(item => {
  233. let temp = {
  234. productName: item.materialName,
  235. productNumber: '',
  236. productSpec: item.specifications,
  237. deleverCode: item.materialCode,
  238. batchNumber: (item.whBatchInfoList == null || item.whBatchInfoList.length === 0) ? '' : item.whBatchInfoList[0].batchNumber,
  239. deliverCnt: item.cnt2,
  240. price: (item.whBatchInfoList === null || item.whBatchInfoList.length === 0) ? '' : item.whBatchInfoList[0].price,
  241. notes: item.notes,
  242. mapNumber: item.mapNumber,
  243. materialId: item.materialId,
  244. unit: item.unitName
  245. }
  246. temp.amount = temp.deliverCnt * temp.price
  247. temp.contractId = this.dataForm.contractId
  248. return temp
  249. })
  250. this.dataForm.list = data
  251. this.addItemVisible = false
  252. }
  253. }
  254. }
  255. </script>
  256. <style scoped lang="scss">
  257. .my-row {
  258. margin-bottom: 0px;
  259. }
  260. .title {
  261. margin-bottom: 5px;
  262. }
  263. /deep/ .el-input-number--mini {
  264. width: 100px;
  265. }
  266. </style>