pickup_form.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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">
  82. <el-table-column align="center" type="selection" width="55"></el-table-column>
  83. <el-table-column align="center" label="发货申请单" prop="invoiceId" min-width="180" show-overflow-tooltip></el-table-column>
  84. <el-table-column align="center" 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="center" label="销售订单号" prop="mainOrderId" min-width="200" show-overflow-tooltip></el-table-column>
  90. <el-table-column align="center" label="工程编号" prop="enginOrderNo" min-width="160" show-overflow-tooltip></el-table-column>
  91. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="160" show-overflow-tooltip></el-table-column>
  92. <el-table-column align="center" label="产品编码" prop="materialCode" min-width="160" show-overflow-tooltip></el-table-column>
  93. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  94. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  95. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
  96. <el-table-column align="center" label="数量" prop="refundableQty" min-width="100" show-overflow-tooltip></el-table-column>
  97. </el-table>
  98. </div>
  99. </div>
  100. <div class="page-footer">
  101. <div class="footer" :class="classObj">
  102. <el-button type="primary" @click="clickSubmitForm" :loading="formLoading">{{ formLoading ? '提交中 ...' : '提 交' }}</el-button>
  103. <el-popconfirm title="确定重置吗?" @onConfirm="resetForm" style="margin-left: 10px;" v-if="!listItem">
  104. <el-button slot="reference">重 置</el-button>
  105. </el-popconfirm>
  106. </div>
  107. </div>
  108. </div>
  109. </template>
  110. <script>
  111. import { getWarehouseList, getDeliverList, getPickupManList, getPickupCarList, getCompanyList, addPickupBook, editPickupBook, getDetail } from "@/api/supply/pickup";
  112. import { getDictList } from "@/api/common";
  113. export default {
  114. name: 'PickupForm',
  115. componentName: 'PickupForm',
  116. props: ['listItem'],
  117. data() {
  118. return {
  119. deliverList: null, // 列表数据
  120. listLoading: false, // 列表加载loading
  121. mainForm: { // 筛选表单数据
  122. warehouse: '',
  123. date: '',
  124. timeSlot: '',
  125. pickupWay: '',
  126. pickupMan: '',
  127. pickupCar: '',
  128. company: '',
  129. remark: '',
  130. },
  131. mainFormRules: {
  132. date: [
  133. { required: true, message: '请选择预约日期', trigger: 'change' }
  134. ],
  135. timeSlot: [
  136. { required: true, message: '请选择预约时段', trigger: 'change' }
  137. ],
  138. pickupWay: [
  139. { required: true, message: '请选择提货方式', trigger: 'change' }
  140. ],
  141. pickupMan: [
  142. { required: true, message: '请选择提货人', trigger: 'change' }
  143. ],
  144. },
  145. formLoading: false,
  146. tableSelection: [],
  147. warehouseList: [],
  148. pickupWayList: [],
  149. pickupManList: [],
  150. pickupCarList: [],
  151. companyList: [],
  152. }
  153. },
  154. computed: {
  155. sidebar() {
  156. return this.$store.state.app.sidebar
  157. },
  158. classObj() {
  159. return {
  160. hideSidebar: !this.sidebar.opened,
  161. openSidebar: this.sidebar.opened
  162. }
  163. },
  164. },
  165. created() {
  166. this.getWarehouseList();
  167. this.getPickupWayList();
  168. this.getPickupManList();
  169. this.getPickupCarList();
  170. this.getCompanyList();
  171. if(this.listItem) {
  172. this.getDetail();
  173. }
  174. },
  175. methods: {
  176. // 查询按钮权限
  177. checkBtnRole(value) {
  178. // let btnRole = this.$route.meta.roles;
  179. // if(!btnRole) {return true}
  180. // let index = btnRole.indexOf(value);
  181. // return index >= 0;
  182. return true
  183. },
  184. // 返回列表
  185. goBack() {
  186. this.$emit('backListFormDetail');
  187. },
  188. // 获取详情
  189. getDetail() {
  190. getDetail({id: this.listItem.id}).then(res => {
  191. let data = res.data;
  192. this.mainForm.warehouse = data.correspondId;
  193. this.mainForm.date = data.pickTime.slice(0, 10);
  194. this.mainForm.timeSlot = Number(data.pickStatus);
  195. this.mainForm.pickupWay = String(data.pickType);
  196. this.mainForm.pickupMan = data.takerId;
  197. this.mainForm.pickupCar = data.takerCarId;
  198. this.mainForm.company = data.pickLogistics;
  199. this.mainForm.remark = data.remark;
  200. this.deliverList = data.invoicePickBeans;
  201. })
  202. },
  203. // 获取仓库列表
  204. getWarehouseList() {
  205. getWarehouseList({
  206. pageNum: 1,
  207. pageSize: -1
  208. }).then((res) => {
  209. this.warehouseList = res.data.records;
  210. })
  211. },
  212. // 获取提货方式列表
  213. getPickupWayList() {
  214. getDictList({sysDictEnum: 'PICK'}).then(res => {
  215. this.pickupWayList = res.data;
  216. })
  217. },
  218. // 获取提货人列表
  219. getPickupManList() {
  220. getPickupManList({
  221. pageNum: 1,
  222. pageSize: -1
  223. }).then(res => {
  224. this.pickupManList = res.data.records;
  225. })
  226. },
  227. // 获取提货车辆列表
  228. getPickupCarList() {
  229. getPickupCarList({
  230. pageNum: 1,
  231. pageSize: -1
  232. }).then(res => {
  233. this.pickupCarList = res.data.records;
  234. })
  235. },
  236. // 获取物流公司列表
  237. getCompanyList() {
  238. getCompanyList({
  239. pageNum: 1,
  240. pageSize: -1
  241. }).then(res => {
  242. this.companyList = res.data.records;
  243. })
  244. },
  245. // 查询列表
  246. getDeliverList() {
  247. if(!this.mainForm.warehouse) {
  248. return this.$errorMsg('请选择仓库');
  249. }
  250. this.listLoading = true;
  251. getDeliverList({correspondId: this.mainForm.warehouse}).then((res) => {
  252. this.deliverList = res.data;
  253. this.listLoading = false;
  254. })
  255. },
  256. handleSelect(selection, row) {
  257. this.$refs.table.toggleRowSelection(row);
  258. this.deliverList.forEach(item => {
  259. if (item.invoiceId === row.invoiceId) {
  260. this.$refs.table.toggleRowSelection(item);
  261. }
  262. })
  263. this.tableSelection = this.$refs.table.selection;
  264. },
  265. clickSubmitForm() {
  266. this.$refs.mainForm.validate((valid) => {
  267. if (valid) {
  268. if(this.tableSelection.length < 1) {
  269. return this.$errorMsg('请选择发货申请单');
  270. }
  271. this.formLoading = true;
  272. let takerName = this.pickupManList.find(o => o.id == this.mainForm.pickupMan).takerName;
  273. let correspondName = this.warehouseList.find(o => o.id == this.mainForm.warehouse).name;
  274. let orderList = [];
  275. this.tableSelection.forEach(item => {
  276. orderList.push(item.invoiceOrderId);
  277. });
  278. let params = {
  279. correspondId: this.mainForm.warehouse,
  280. correspondName,
  281. pickTime: this.mainForm.date + ' 00:00:00',
  282. pickStatus: Number(this.mainForm.timeSlot),
  283. pickType: Number(this.mainForm.pickupWay),
  284. takerId: this.mainForm.pickupMan,
  285. takerName,
  286. remark: this.mainForm.remark,
  287. invoiceOrderIds: orderList,
  288. }
  289. if(this.mainForm.pickupWay == '1') {
  290. params.takerCarId = this.mainForm.pickupCar;
  291. }
  292. if(this.mainForm.pickupWay == '2') {
  293. params.pickLogistics = this.mainForm.company;
  294. }
  295. if(this.listItem) {
  296. params.id = this.listItem.id;
  297. editPickupBook(params).then(res => {
  298. this.$successMsg('提交成功');
  299. this.goBack();
  300. this.$parent.getList();
  301. }).finally(res => {
  302. this.formLoading = false;
  303. })
  304. }else {
  305. addPickupBook(params).then(res => {
  306. this.$successMsg('提交成功');
  307. this.goBack();
  308. this.$parent.getList();
  309. }).finally(res => {
  310. this.formLoading = false;
  311. })
  312. }
  313. }
  314. })
  315. },
  316. resetForm() {
  317. this.$refs.mainForm.resetFields();
  318. this.deliverList = [];
  319. },
  320. }
  321. }
  322. </script>
  323. <style lang="scss" scoped>
  324. </style>