pickup_form.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header @back="goBack" :content="listItem ? '编辑':'新增'"></el-page-header>
  4. <el-divider></el-divider>
  5. <div>
  6. <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-width="80px" size="small" label-position="left">
  7. <el-row :gutter="20">
  8. <el-col :xs="24" :sm="12" :lg="8">
  9. <el-form-item label="选择仓库" prop="warehouse">
  10. <el-select v-model="mainForm.warehouse" placeholder="请选择仓库" style="width: 100%">
  11. <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
  12. </el-select>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :xs="24" :sm="12" :lg="8">
  16. <el-button size="small" type="primary" @click="getDeliverList">确定</el-button>
  17. </el-col>
  18. </el-row>
  19. <el-row :gutter="20">
  20. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  21. <el-form-item label="预约日期" prop="date">
  22. <el-date-picker
  23. v-model="mainForm.date"
  24. type="date"
  25. value-format="yyyy-MM-dd"
  26. style="width: 100%;"
  27. placeholder="选择日期">
  28. </el-date-picker>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :xs="24" :sm="12" :lg="12" style="height: 51px;">
  32. <el-form-item label="预约时段" prop="timeSlot">
  33. <el-radio-group v-model="mainForm.timeSlot">
  34. <el-radio :label="1">上午</el-radio>
  35. <el-radio :label="2">下午</el-radio>
  36. </el-radio-group>
  37. </el-form-item>
  38. </el-col>
  39. </el-row>
  40. <el-row :gutter="20">
  41. <el-col :xs="24" :sm="12" :lg="8">
  42. <el-form-item label="提货方式" prop="pickupWay">
  43. <el-radio-group v-model="mainForm.pickupWay">
  44. <el-radio :label="item.dictCode" v-for="(item, index) in pickupWayList" :key="index">{{item.dictValue}}</el-radio>
  45. </el-radio-group>
  46. </el-form-item>
  47. </el-col>
  48. <el-col :xs="24" :sm="12" :lg="8">
  49. <el-form-item label="提货人" prop="pickupMan">
  50. <el-select v-model="mainForm.pickupMan" placeholder="全部" style="width: 100%">
  51. <el-option :label="item.takerName" :value="item.id" v-for="(item, index) in pickupManList" :key="index"></el-option>
  52. </el-select>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :xs="24" :sm="12" :lg="8" v-if="mainForm.pickupWay == '1'">
  56. <el-form-item label="提货车辆" prop="pickupCar">
  57. <el-select v-model="mainForm.pickupCar" placeholder="全部" style="width: 100%">
  58. <el-option :label="item.carBrand" :value="item.id" v-for="(item, index) in pickupCarList" :key="index"></el-option>
  59. </el-select>
  60. </el-form-item>
  61. </el-col>
  62. <el-col :xs="24" :sm="12" :lg="8" v-if="mainForm.pickupWay == '2'">
  63. <el-form-item label="物流公司" prop="company">
  64. <el-select v-model="mainForm.company" placeholder="全部" style="width: 100%">
  65. <el-option :label="item.logisticsCompany" :value="item.logisticsNumber" v-for="(item, index) in companyList" :key="index"></el-option>
  66. </el-select>
  67. </el-form-item>
  68. </el-col>
  69. </el-row>
  70. <el-row :gutter="20">
  71. <el-col :xs="24" :sm="24" :lg="24">
  72. <el-form-item label="备注内容" prop="remark">
  73. <el-input v-model="mainForm.remark" placeholder="请输入备注内容"></el-input>
  74. </el-form-item>
  75. </el-col>
  76. </el-row>
  77. </el-form>
  78. </div>
  79. <div class="mymain-container">
  80. <div class="table">
  81. <el-table ref="table" v-loading="listLoading" :data="deliverList" element-loading-text="Loading" border fit highlight-current-row stripe @select="handleSelect" @select-all="handleSelectAll">
  82. <el-table-column align="center" type="selection" width="55"></el-table-column>
  83. <el-table-column align="left" label="发货申请单" prop="invoiceId" min-width="160" show-overflow-tooltip></el-table-column>
  84. <el-table-column align="left" label="单据日期" prop="orderTime" min-width="120" show-overflow-tooltip>
  85. <template slot-scope="scope">
  86. {{ scope.row.orderTime | dateToDayFilter }}
  87. </template>
  88. </el-table-column>
  89. <el-table-column align="left" label="销售订单号" prop="mainOrderId" min-width="160" show-overflow-tooltip>
  90. <template slot-scope="scope">
  91. <CopyButton :copyText="scope.row.orderType == 'TRADE' ? scope.row.enginOrderNo: scope.row.mainOrderId" />
  92. <span>{{ scope.row.orderType == 'TRADE' ? scope.row.enginOrderNo: scope.row.mainOrderId }}</span>
  93. </template>
  94. </el-table-column>
  95. <el-table-column align="left" label="工程编号" prop="enginOrderNo" min-width="140" show-overflow-tooltip></el-table-column>
  96. <el-table-column align="left" label="销售类型" prop="saleTypeName" min-width="160" show-overflow-tooltip></el-table-column>
  97. <el-table-column align="left" label="产品编码" prop="materialCode" min-width="160" show-overflow-tooltip></el-table-column>
  98. <el-table-column align="left" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  99. <el-table-column align="left" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  100. <el-table-column align="left" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
  101. <el-table-column align="right" label="数量" prop="refundableQty" min-width="100" show-overflow-tooltip></el-table-column>
  102. </el-table>
  103. </div>
  104. </div>
  105. <div class="page-footer">
  106. <div class="footer" :class="classObj">
  107. <el-button type="primary" @click="clickSubmitForm" :loading="formLoading">{{ formLoading ? '提交中 ...' : '提 交' }}</el-button>
  108. <el-popconfirm title="确定重置吗?" @onConfirm="resetForm" style="margin-left: 10px;" v-if="!listItem">
  109. <el-button slot="reference">重 置</el-button>
  110. </el-popconfirm>
  111. </div>
  112. </div>
  113. </div>
  114. </template>
  115. <script>
  116. import { getWarehouseList, getDeliverList, getPickupManList, getPickupCarList, getCompanyList, addPickupBook, editPickupBook, getDetail, checkStock } from "@/api/supply/pickup";
  117. import { getDictList } from "@/api/common";
  118. export default {
  119. name: 'PickupForm',
  120. componentName: 'PickupForm',
  121. props: ['listItem'],
  122. data() {
  123. return {
  124. deliverList: null, // 列表数据
  125. listLoading: false, // 列表加载loading
  126. mainForm: { // 筛选表单数据
  127. warehouse: '',
  128. date: '',
  129. timeSlot: '',
  130. pickupWay: '',
  131. pickupMan: '',
  132. pickupCar: '',
  133. company: '',
  134. remark: '',
  135. },
  136. mainFormRules: {
  137. date: [
  138. { required: true, message: '请选择预约日期', trigger: 'change' }
  139. ],
  140. timeSlot: [
  141. { required: true, message: '请选择预约时段', trigger: 'change' }
  142. ],
  143. pickupWay: [
  144. { required: true, message: '请选择提货方式', trigger: 'change' }
  145. ],
  146. pickupMan: [
  147. { required: true, message: '请选择提货人', trigger: 'change' }
  148. ],
  149. },
  150. formLoading: false,
  151. tableSelection: [],
  152. warehouseList: [],
  153. pickupWayList: [],
  154. pickupManList: [],
  155. pickupCarList: [],
  156. companyList: [],
  157. }
  158. },
  159. computed: {
  160. sidebar() {
  161. return this.$store.state.app.sidebar
  162. },
  163. classObj() {
  164. return {
  165. hideSidebar: !this.sidebar.opened,
  166. openSidebar: this.sidebar.opened
  167. }
  168. },
  169. },
  170. created() {
  171. this.getWarehouseList();
  172. this.getPickupWayList();
  173. this.getPickupManList();
  174. this.getPickupCarList();
  175. this.getCompanyList();
  176. if(this.listItem) {
  177. this.getDetail();
  178. }
  179. },
  180. methods: {
  181. // 查询按钮权限
  182. checkBtnRole(value) {
  183. // let btnRole = this.$route.meta.roles;
  184. // if(!btnRole) {return true}
  185. // let index = btnRole.indexOf(value);
  186. // return index >= 0;
  187. return true
  188. },
  189. // 返回列表
  190. goBack() {
  191. this.$emit('backListFormDetail');
  192. },
  193. // 获取详情
  194. getDetail() {
  195. getDetail({id: this.listItem.id}).then(res => {
  196. let data = res.data;
  197. this.mainForm.warehouse = data.correspondId;
  198. this.mainForm.date = data.pickTime.slice(0, 10);
  199. this.mainForm.timeSlot = Number(data.pickStatus);
  200. this.mainForm.pickupWay = String(data.pickType);
  201. this.mainForm.pickupMan = data.takerId;
  202. this.mainForm.pickupCar = data.takerCarId;
  203. this.mainForm.company = data.pickLogistics;
  204. this.mainForm.remark = data.remark;
  205. this.deliverList = data.invoicePickBeans;
  206. })
  207. },
  208. // 获取仓库列表
  209. getWarehouseList() {
  210. getWarehouseList({
  211. pageNum: 1,
  212. pageSize: -1
  213. }).then((res) => {
  214. this.warehouseList = res.data.records;
  215. })
  216. },
  217. // 获取提货方式列表
  218. getPickupWayList() {
  219. getDictList({sysDictEnum: 'PICK'}).then(res => {
  220. this.pickupWayList = res.data;
  221. })
  222. },
  223. // 获取提货人列表
  224. getPickupManList() {
  225. getPickupManList({
  226. pageNum: 1,
  227. pageSize: -1
  228. }).then(res => {
  229. this.pickupManList = res.data.records;
  230. })
  231. },
  232. // 获取提货车辆列表
  233. getPickupCarList() {
  234. getPickupCarList({
  235. pageNum: 1,
  236. pageSize: -1
  237. }).then(res => {
  238. this.pickupCarList = res.data.records;
  239. })
  240. },
  241. // 获取物流公司列表
  242. getCompanyList() {
  243. getCompanyList({
  244. pageNum: 1,
  245. pageSize: -1
  246. }).then(res => {
  247. this.companyList = res.data.records;
  248. })
  249. },
  250. // 查询列表
  251. getDeliverList() {
  252. if(!this.mainForm.warehouse) {
  253. return this.$errorMsg('请选择仓库');
  254. }
  255. this.listLoading = true;
  256. getDeliverList({correspondId: this.mainForm.warehouse}).then((res) => {
  257. this.deliverList = res.data;
  258. this.listLoading = false;
  259. })
  260. },
  261. handleSelect(selection, row) {
  262. this.$refs.table.toggleRowSelection(row);
  263. this.deliverList.forEach(item => {
  264. if (item.invoiceId === row.invoiceId) {
  265. this.$refs.table.toggleRowSelection(item);
  266. }
  267. })
  268. this.tableSelection = this.$refs.table.selection;
  269. },
  270. handleSelectAll(selection) {
  271. this.tableSelection = this.$refs.table.selection;
  272. },
  273. clickSubmitForm() {
  274. this.$refs.mainForm.validate((valid) => {
  275. if (valid) {
  276. if(this.tableSelection.length < 1) {
  277. return this.$errorMsg('请选择发货申请单');
  278. }
  279. let orderList = [];
  280. this.tableSelection.forEach(item => {
  281. orderList.push(item.invoiceOrderId);
  282. });
  283. let params = {
  284. correspondId: this.mainForm.warehouse,
  285. pickTime: this.mainForm.date + ' 00:00:00',
  286. invoiceOrderIds: orderList.join(','),
  287. }
  288. checkStock(params).then(res => {
  289. if(res.data) {
  290. this.$confirm(res.data, '提示', {
  291. confirmButtonText: '确定',
  292. cancelButtonText: '取消',
  293. type: 'warning'
  294. }).then(() => {
  295. this.submitForm();
  296. }).catch(() => {});
  297. }else {
  298. this.submitForm();
  299. }
  300. })
  301. }
  302. })
  303. },
  304. submitForm() {
  305. this.formLoading = true;
  306. let takerName = this.pickupManList.find(o => o.id == this.mainForm.pickupMan).takerName;
  307. // let correspondName = this.warehouseList.find(o => o.id == this.mainForm.warehouse).name;
  308. let orderList = [];
  309. this.tableSelection.forEach(item => {
  310. orderList.push(item.invoiceOrderId);
  311. });
  312. let params = {
  313. correspondId: this.mainForm.warehouse,
  314. // correspondName,
  315. pickTime: this.mainForm.date + ' 00:00:00',
  316. pickStatus: Number(this.mainForm.timeSlot),
  317. pickType: Number(this.mainForm.pickupWay),
  318. takerId: this.mainForm.pickupMan,
  319. takerName,
  320. remark: this.mainForm.remark,
  321. invoiceOrderIds: orderList,
  322. }
  323. if(this.mainForm.pickupWay == '1') {
  324. params.takerCarId = this.mainForm.pickupCar;
  325. }
  326. if(this.mainForm.pickupWay == '2') {
  327. params.pickLogistics = this.mainForm.company;
  328. }
  329. if(this.listItem) {
  330. params.id = this.listItem.id;
  331. editPickupBook(params).then(res => {
  332. this.$successMsg('提交成功');
  333. this.goBack();
  334. this.$parent.getList();
  335. }).finally(res => {
  336. this.formLoading = false;
  337. })
  338. }else {
  339. addPickupBook(params).then(res => {
  340. this.$successMsg('提交成功');
  341. this.goBack();
  342. this.$parent.getList();
  343. }).finally(res => {
  344. this.formLoading = false;
  345. })
  346. }
  347. },
  348. resetForm() {
  349. this.$refs.mainForm.resetFields();
  350. this.deliverList = [];
  351. },
  352. }
  353. }
  354. </script>
  355. <style lang="scss" scoped>
  356. </style>