reserve_form.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header @back="goBack" :content="listItem ? '编辑':'新增'"></el-page-header>
  4. <div class="main-title">
  5. <div class="title">预留单信息</div>
  6. </div>
  7. <el-form ref="mainForm" :model="mainForm" label-width="70px" size="small" label-position="left">
  8. <el-row :gutter="20">
  9. <el-col :xs="24" :sm="12" :lg="6">
  10. <el-form-item label="单据编号" prop="orderNum">
  11. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" disabled></el-input>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :xs="24" :sm="12" :lg="6" style="height: 51px;">
  15. <el-form-item label="单据日期" prop="orderDate">
  16. <el-date-picker
  17. v-model="mainForm.orderDate"
  18. disabled
  19. type="date"
  20. value-format="yyyy-MM-dd"
  21. style="width: 100%;"
  22. placeholder="系统自动生成">
  23. </el-date-picker>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :xs="24" :sm="12" :lg="6">
  27. <el-form-item label="制单人" prop="createMan">
  28. <el-input v-model="mainForm.createMan" placeholder="请输入制单人" disabled></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :xs="24" :sm="12" :lg="6" style="height: 51px;">
  32. <el-form-item label="制单日期" prop="createDate">
  33. <el-date-picker
  34. v-model="mainForm.createDate"
  35. disabled
  36. type="datetime"
  37. value-format="yyyy-MM-dd HH:mm:ss"
  38. style="width: 100%;"
  39. placeholder="选择日期">
  40. </el-date-picker>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :xs="24" :sm="24" :lg="24">
  44. <el-form-item label="备注" prop="remark">
  45. <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
  46. </el-form-item>
  47. </el-col>
  48. </el-row>
  49. </el-form>
  50. <div style="margin-top: 20px">
  51. <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog" v-if="!listItem">添加引用</el-button>
  52. <el-button type="danger" size="small" icon="el-icon-minus" @click="deleteGoods" :disabled="tableSelection.length < 1" v-if="!listItem">批量删除</el-button>
  53. <el-button size="small" icon="el-icon-edit" @click="batchChangeNum" :disabled="tableSelection.length < 1" v-if="!listItem">批量设置预留数量</el-button>
  54. </div>
  55. <div class="table" style="margin-top: 20px">
  56. <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400" @selection-change="tableSelectionChange">
  57. <el-table-column align="center" type="selection" width="55"></el-table-column>
  58. <el-table-column align="center" label="销售订单号" prop="orderId" min-width="200" show-overflow-tooltip></el-table-column>
  59. <el-table-column align="center" label="订单日期" prop="orderTime" min-width="120" show-overflow-tooltip>
  60. <template slot-scope="scope">
  61. {{scope.row.orderTime | dateToDayFilter}}
  62. </template>
  63. </el-table-column>
  64. <el-table-column align="center" label="经销商编码" prop="customerNumber" min-width="120" show-overflow-tooltip>
  65. <template slot-scope="scope">
  66. <div v-if="scope.row.orderId || listItem">{{scope.row.customerNumber}}</div>
  67. <el-select
  68. v-else
  69. v-model="scope.row.customerNumber"
  70. placeholder="选择经销商"
  71. size="small"
  72. filterable
  73. remote
  74. clearable
  75. :remote-method="checkDealerList"
  76. @change="changeDealer(scope.$index)">
  77. <el-option
  78. v-for="item in dealerList"
  79. :key="item.number"
  80. :label="item.number"
  81. :value="item.number">
  82. <span>{{ item.number }}</span>
  83. <span style="color: #8492a6; font-size: 13px; margin-left: 6px">{{ item.name }}</span>
  84. </el-option>
  85. </el-select>
  86. </template>
  87. </el-table-column>
  88. <el-table-column align="center" label="经销商名称" prop="customerName" min-width="160" show-overflow-tooltip></el-table-column>
  89. <el-table-column align="center" label="产品编码" prop="materialCode" min-width="160" show-overflow-tooltip>
  90. <template slot-scope="scope">
  91. <div v-if="scope.row.orderId || listItem">{{scope.row.materialCode}}</div>
  92. <el-select
  93. v-else
  94. v-model="scope.row.materialCode"
  95. placeholder="选择产品"
  96. size="small"
  97. filterable
  98. remote
  99. clearable
  100. :remote-method="checkMaterialList"
  101. @change="changeMaterial(scope.$index)">
  102. <el-option
  103. v-for="item in materialList"
  104. :key="item.number"
  105. :label="item.number"
  106. :value="item.number">
  107. <span>{{ item.number }}</span>
  108. <span style="color: #8492a6; font-size: 13px; margin-left: 6px">{{ item.name }}</span>
  109. </el-option>
  110. </el-select>
  111. </template>
  112. </el-table-column>
  113. <el-table-column align="center" label="物料代码" prop="materialOldNumber" min-width="160" show-overflow-tooltip></el-table-column>
  114. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  115. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  116. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
  117. <el-table-column align="center" label="原预留数量" prop="oldNum" min-width="100" show-overflow-tooltip></el-table-column>
  118. <el-table-column align="center" label="预留数量" prop="reservedNum" min-width="100" show-overflow-tooltip>
  119. <template slot-scope="scope">
  120. <el-input v-model="scope.row.reservedNum" size="small"></el-input>
  121. </template>
  122. </el-table-column>
  123. <el-table-column align="center" label="订单数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
  124. <el-table-column align="center" label="可用数量" prop="openNumber" min-width="100" show-overflow-tooltip></el-table-column>
  125. <el-table-column align="center" label="预留仓库" prop="correspondId" min-width="160" show-overflow-tooltip>
  126. <template slot-scope="scope">
  127. <el-select v-model="scope.row.correspondId" placeholder="选择预留仓库" size="small" clearable @change="changeWarehouse(scope.$index)">
  128. <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
  129. </el-select>
  130. </template>
  131. </el-table-column>
  132. <el-table-column align="center" label="备注" prop="reservedRemark" min-width="160" show-overflow-tooltip></el-table-column>
  133. <el-table-column align="center" label="状态" prop="status" min-width="100" show-overflow-tooltip>
  134. <template slot-scope="scope">
  135. {{scope.row.status ? '执行中':'已关闭'}}
  136. </template>
  137. </el-table-column>
  138. <el-table-column align="center" label="操作" width="100" fixed="right">
  139. <template slot-scope="scope">
  140. <el-button type="text" @click="deleteItem(scope.$index)" v-if="!listItem">删除</el-button>
  141. <el-button type="text" @click="changeItem(scope.$index, 0)" v-if="listItem && scope.row.status === 1">关闭</el-button>
  142. <el-button type="text" @click="changeItem(scope.$index, 1)" v-if="listItem && scope.row.status === 0">开启</el-button>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. <div class="add" v-if="!listItem"><el-button type="text" icon="el-icon-plus" @click="addGoods">添加行</el-button></div>
  147. </div>
  148. <div class="page-footer">
  149. <div class="footer">
  150. <el-button type="primary" @click="clickSubmitForm">保 存</el-button>
  151. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
  152. <el-button slot="reference">关 闭</el-button>
  153. </el-popconfirm>
  154. </div>
  155. </div>
  156. <el-dialog title="添加引用" :visible.sync="isShowDialog" width="80%">
  157. <el-form ref="screenForm" :model="screenForm" size="small" label-position="left">
  158. <el-row :gutter="20">
  159. <el-col :xs="12" :sm="6" :lg="4">
  160. <el-form-item prop="jxsNum">
  161. <el-input v-model="screenForm.jxsNum" placeholder="经销商编码"></el-input>
  162. </el-form-item>
  163. </el-col>
  164. <el-col :xs="12" :sm="6" :lg="4">
  165. <el-form-item prop="jxsName">
  166. <el-input v-model="screenForm.jxsName" placeholder="经销商名称"></el-input>
  167. </el-form-item>
  168. </el-col>
  169. <el-col :xs="12" :sm="6" :lg="4">
  170. <el-form-item prop="type">
  171. <el-select v-model="screenForm.type" placeholder="产品大类" style="width: 100%">
  172. <el-option v-for="item in typeList" :key="item.dictValue" :label="item.dictValue" :value="item.dictValue"></el-option>
  173. </el-select>
  174. </el-form-item>
  175. </el-col>
  176. <el-col :xs="12" :sm="6" :lg="4">
  177. <el-form-item prop="goodsNum">
  178. <el-input v-model="screenForm.goodsNum" placeholder="产品编码"></el-input>
  179. </el-form-item>
  180. </el-col>
  181. <el-col :xs="12" :sm="6" :lg="4">
  182. <el-form-item prop="goodsCode">
  183. <el-input v-model="screenForm.goodsCode" placeholder="物料代码"></el-input>
  184. </el-form-item>
  185. </el-col>
  186. <el-col :xs="12" :sm="6" :lg="4">
  187. <el-form-item prop="goodsName">
  188. <el-input v-model="screenForm.goodsName" placeholder="产品名称"></el-input>
  189. </el-form-item>
  190. </el-col>
  191. <el-col :xs="12" :sm="6" :lg="4">
  192. <el-form-item prop="model">
  193. <el-input v-model="screenForm.model" placeholder="规格型号"></el-input>
  194. </el-form-item>
  195. </el-col>
  196. <el-col :xs="12" :sm="6" :lg="4">
  197. <el-form-item prop="orderType">
  198. <el-select v-model="screenForm.orderType" placeholder="订单类型" style="width: 100%">
  199. <el-option v-for="item in orderTypeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
  200. </el-select>
  201. </el-form-item>
  202. </el-col>
  203. <el-col :xs="12" :sm="6" :lg="4">
  204. <el-form-item prop="saleNum">
  205. <el-input v-model="screenForm.saleNum" placeholder="销售订单号"></el-input>
  206. </el-form-item>
  207. </el-col>
  208. <el-col :xs="12" :sm="18" :lg="12" class="tr">
  209. <el-form-item label="">
  210. <el-button size="small" @click="resetScreenForm">清空</el-button>
  211. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  212. </el-form-item>
  213. </el-col>
  214. </el-row>
  215. </el-form>
  216. <div class="table">
  217. <el-table :data="dialogGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="dialogSelectionChange">
  218. <el-table-column align="center" type="selection" width="55" :selectable='checkboxSelect'></el-table-column>
  219. <el-table-column align="center" label="经销商编码" prop="customerNumber" min-width="120" show-overflow-tooltip></el-table-column>
  220. <el-table-column align="center" label="经销商名称" prop="customerName" min-width="160" show-overflow-tooltip></el-table-column>
  221. <el-table-column align="center" label="订单日期" prop="orderTime" min-width="120" show-overflow-tooltip>
  222. <template slot-scope="scope">
  223. {{scope.row.orderTime | dateToDayFilter}}
  224. </template>
  225. </el-table-column>
  226. <el-table-column align="center" label="订单类型" prop="orderType" min-width="100" show-overflow-tooltip>
  227. <template slot-scope="scope">
  228. {{scope.row.orderType | orderTypeFilter}}
  229. </template>
  230. </el-table-column>
  231. <el-table-column align="center" label="订单号" prop="orderId" min-width="180" show-overflow-tooltip></el-table-column>
  232. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
  233. <el-table-column align="center" label="产品编码" prop="materialCode" min-width="160" show-overflow-tooltip></el-table-column>
  234. <el-table-column align="center" label="物料代码" prop="materialOldNumber" min-width="160" show-overflow-tooltip></el-table-column>
  235. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  236. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  237. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
  238. <el-table-column align="center" label="订单数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
  239. </el-table>
  240. <div class="pagination clearfix" style="margin-top: 10px">
  241. <div class="fr">
  242. <el-pagination
  243. @current-change="handleTableCurrentChange"
  244. :current-page="currentPage"
  245. :page-size="10"
  246. background
  247. layout="prev, pager, next"
  248. :total="listTotal">
  249. </el-pagination>
  250. </div>
  251. </div>
  252. </div>
  253. <span slot="footer" class="dialog-footer">
  254. <el-button @click="closeDialog">取 消</el-button>
  255. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  256. </span>
  257. </el-dialog>
  258. </div>
  259. </template>
  260. <script>
  261. import { getDetail, getGoodsList, addData, editData, checkDealerList, checkMaterialList, getWarehouseList } from "@/api/supply/reserve";
  262. import { getDictList } from '@/api/common'
  263. let that
  264. export default {
  265. name: 'ReserveForm',
  266. componentName: 'ReserveForm',
  267. props: ['listItem'],
  268. filters: {
  269. orderTypeFilter(val) {
  270. let obj = that.orderTypeFilterList.find(o => o.value == val);
  271. return obj ? obj.label : ''
  272. }
  273. },
  274. data() {
  275. return {
  276. mainForm: {
  277. orderNum: '',
  278. orderDate: '',
  279. createMan: '',
  280. createDate: '',
  281. remark: '',
  282. },
  283. goodsList: [],
  284. tableSelection: [],
  285. typeList: [],
  286. orderTypeList: [
  287. { label: '商用工程单', value: 'TRADE' },
  288. { label: '家用工程单', value: 'HOME' },
  289. { label: '零售单', value: 'RETAIL' },
  290. { label: '销售政策单', value: 'RETAIL_POLICY' },
  291. { label: '置换单', value: 'PERMU' },
  292. ],
  293. orderTypeFilterList: [
  294. { label: '商用工程单', value: 'TRADE' },
  295. { label: '家用工程单', value: 'HOME' },
  296. { label: '零售单', value: 'RETAIL' },
  297. { label: '销售政策单', value: 'RETAIL_POLICY' },
  298. { label: '置换单', value: 'PERMU_HOME' },
  299. { label: '置换单', value: 'PERMU_TRADE' },
  300. { label: '置换单', value: 'PERMU_RETAIL' },
  301. { label: '置换单', value: 'PERMU_RETAIL_POLICY' },
  302. ],
  303. isShowDialog: false,
  304. screenForm: {
  305. jxsNum: '',
  306. jxsName: '',
  307. type: '',
  308. goodsNum: '',
  309. goodsCode: '',
  310. goodsName: '',
  311. model: '',
  312. orderType: '',
  313. saleNum: '',
  314. },
  315. currentPage: 1,
  316. listTotal: 0,
  317. dialogGoodsList: [],
  318. dialogSelection: [],
  319. dealerList: [],
  320. materialList: [],
  321. warehouseList: [],
  322. }
  323. },
  324. beforeCreate() {
  325. that = this;
  326. },
  327. async created() {
  328. await this.getWarehouseList();
  329. if(this.listItem) {
  330. this.getDetail();
  331. }else {
  332. this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
  333. this.mainForm.createDate = this.getDate();
  334. }
  335. },
  336. methods: {
  337. getDate() {
  338. var date = new Date();
  339. var seperator1 = "-";
  340. var year = date.getFullYear();
  341. var month = date.getMonth() + 1;
  342. var strDate = date.getDate();
  343. if (month >= 1 && month <= 9) {
  344. month = "0" + month;
  345. }
  346. if (strDate >= 0 && strDate <= 9) {
  347. strDate = "0" + strDate;
  348. }
  349. var currentdate = year + seperator1 + month + seperator1 + strDate;
  350. return currentdate;
  351. },
  352. getDictList() {
  353. getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
  354. this.typeList = res.data;
  355. })
  356. },
  357. // 获取仓库列表
  358. async getWarehouseList() {
  359. const res = await getWarehouseList({
  360. pageNum: 1,
  361. pageSize: -1,
  362. });
  363. this.warehouseList = res.data.records;
  364. },
  365. // 返回列表
  366. goBack() {
  367. this.$emit('backListFormDetail');
  368. },
  369. // 获取详情
  370. getDetail() {
  371. getDetail({id: this.listItem.id}).then(res => {
  372. let data = res.data;
  373. this.mainForm.orderNum = data.id;
  374. this.mainForm.orderDate = data.orderTime;
  375. this.mainForm.createMan = data.createBy;
  376. this.mainForm.createDate = data.createTime;
  377. this.mainForm.remark = data.remark;
  378. this.goodsList = data.reservedOrderItems;
  379. })
  380. },
  381. // 获取商品列表
  382. getGoodsList() {
  383. getGoodsList({
  384. pageNum: this.currentPage,
  385. pageSize: 10,
  386. customerNumber: this.screenForm.jxsNum,
  387. customerName: this.screenForm.jxsName,
  388. mainName: this.screenForm.type,
  389. materialCode: this.screenForm.goodsNum,
  390. materialOldNumber: this.screenForm.goodsCode,
  391. materialName: this.screenForm.goodsName,
  392. specification: this.screenForm.model,
  393. orderType: this.screenForm.orderType,
  394. orderId: this.screenForm.saleNum,
  395. }).then(res => {
  396. res.data.records.forEach(item => {
  397. item.status = 1;
  398. item.reservedStatus = 1;
  399. });
  400. let oldGoodsList = this.goodsList;
  401. let newGoodsList = res.data.records;
  402. for(let i = 0; i < oldGoodsList.length; i++) {
  403. let oldItem = oldGoodsList[i]
  404. for(let j = 0; j < newGoodsList.length; j++) {
  405. let newItem = newGoodsList[j]
  406. if(newItem.orderId === oldItem.orderId){
  407. newGoodsList[j].selected = true;
  408. break;
  409. }
  410. }
  411. }
  412. this.dialogGoodsList = newGoodsList;
  413. this.listTotal = res.data.total;
  414. })
  415. },
  416. // 查询重复值并禁选
  417. checkboxSelect(row, rowIndex) {
  418. if (row.selected) {
  419. return false // 禁用
  420. }else{
  421. return true // 不禁用
  422. }
  423. },
  424. // 点击 选择商品
  425. openDialog() {
  426. this.isShowDialog = true;
  427. this.getDictList();
  428. this.getGoodsList();
  429. },
  430. // 提交筛选表单
  431. submitScreenForm() {
  432. this.currentPage = 1;
  433. this.getGoodsList();
  434. },
  435. // 重置筛选表单
  436. resetScreenForm() {
  437. this.$refs.screenForm.resetFields();
  438. this.currentPage = 1;
  439. this.dialogGoodsList = [];
  440. this.getGoodsList();
  441. },
  442. // 更改列表当前页
  443. handleTableCurrentChange(val) {
  444. if(this.dialogSelection.length > 0) {
  445. return this.$errorMsg('已选择产品不可切换');
  446. }
  447. this.currentPage = val;
  448. this.getGoodsList();
  449. },
  450. // 关闭 弹窗
  451. closeDialog() {
  452. this.$refs.screenForm.resetFields();
  453. this.isShowDialog = false;
  454. },
  455. // 列表选择
  456. dialogSelectionChange(val) {
  457. this.dialogSelection = val;
  458. },
  459. // 确定 添加产品
  460. submitAddGoods() {
  461. this.goodsList = this.goodsList.concat(this.dialogSelection);
  462. this.isShowDialog = false;
  463. this.dialogGoodsList = [];
  464. },
  465. // 删除产品
  466. deleteItem(index) {
  467. this.goodsList.splice(index, 1);
  468. },
  469. // 修改状态
  470. changeItem(index, status) {
  471. this.goodsList[index].status = status;
  472. },
  473. tableSelectionChange(val) {
  474. this.tableSelection = val;
  475. },
  476. // 批量删除
  477. deleteGoods() {
  478. let goodsList = this.goodsList;
  479. let tableSelection = this.tableSelection;
  480. for(let i = 0; i < goodsList.length; i++) {
  481. for(let j = 0; j < tableSelection.length; j++) {
  482. if(tableSelection[j].orderId == goodsList[i].orderId){
  483. this.goodsList.splice(i, 1);
  484. }
  485. }
  486. }
  487. },
  488. // 批量修改数量
  489. batchChangeNum() {
  490. this.$prompt('请输入预留数量', '批量设置', {
  491. confirmButtonText: '确定',
  492. cancelButtonText: '取消',
  493. inputValidator: function(value) {
  494. if(!value) return '请输入预留数量'
  495. },
  496. }).then(({ value }) => {
  497. this.tableSelection.forEach(item => {
  498. item.reservedNum = value;
  499. })
  500. }).catch(() => {});
  501. },
  502. // 添加产品
  503. addGoods() {
  504. this.goodsList.push({
  505. reservedStatus: 2,
  506. status: 1
  507. })
  508. },
  509. // 查询经销商列表
  510. checkDealerList(query) {
  511. checkDealerList({
  512. number: query,
  513. }).then(res => {
  514. this.dealerList = res.data || [];
  515. })
  516. },
  517. // 更改经销商
  518. changeDealer(index) {
  519. if(this.goodsList[index].customerNumber) {
  520. let obj = this.dealerList.find(o => o.number == this.goodsList[index].customerNumber);
  521. this.goodsList[index].customerName = obj.name;
  522. this.goodsList[index].customerId = obj.id;
  523. }else {
  524. this.goodsList[index].customerName = '';
  525. this.goodsList[index].customerId = '';
  526. }
  527. },
  528. // 查询产品
  529. checkMaterialList(query) {
  530. checkMaterialList({
  531. number: query,
  532. }).then(res => {
  533. this.materialList = res.data || [];
  534. })
  535. },
  536. // 更改产品
  537. changeMaterial(index) {
  538. if(this.goodsList[index].materialCode) {
  539. let obj = this.materialList.find(o => o.number == this.goodsList[index].materialCode);
  540. this.goodsList[index].materialName = obj.name;
  541. this.goodsList[index].materialId = obj.id;
  542. this.goodsList[index].materialOldNumber = obj.oldNumber;
  543. this.goodsList[index].specification = obj.specification;
  544. this.goodsList[index].unit = obj.baseUnitId;
  545. }else {
  546. this.goodsList[index].materialName = '';
  547. this.goodsList[index].materialId = '';
  548. this.goodsList[index].materialOldNumber = '';
  549. this.goodsList[index].specification = '';
  550. this.goodsList[index].unit = '';
  551. }
  552. },
  553. // 修改仓库
  554. changeWarehouse(index) {
  555. if(this.goodsList[index].correspondId) {
  556. let obj = this.warehouseList.find(o => o.id == this.goodsList[index].correspondId);
  557. this.goodsList[index].correspondName = obj.name;
  558. }else {
  559. this.goodsList[index].correspondName = '';
  560. }
  561. },
  562. // 提交
  563. clickSubmitForm() {
  564. this.$refs.mainForm.validate((valid) => {
  565. if (valid) {
  566. let params = {
  567. // orderTime: this.mainForm.orderDate + ' 00:00:00',
  568. remark: this.mainForm.remark,
  569. reservedOrderItems: this.goodsList,
  570. }
  571. if(this.listItem) {
  572. params.id = this.listItem.id;
  573. editData(params).then(res => {
  574. this.$successMsg('编辑成功');
  575. this.goBack();
  576. this.$parent.getList();
  577. })
  578. }else {
  579. addData(params).then(res => {
  580. this.$successMsg('添加成功');
  581. this.goBack();
  582. this.$parent.getList();
  583. })
  584. }
  585. }
  586. })
  587. },
  588. }
  589. }
  590. </script>
  591. <style scoped lang="scss">
  592. .detail-container {
  593. width: 100%;
  594. height: 100%;
  595. }
  596. .main-title {
  597. display: flex;
  598. justify-content: space-between;
  599. align-items: center;
  600. margin-top: 20px;
  601. height: 60px;
  602. border-bottom: 1px solid #DCDFE6;
  603. margin-bottom: 20px;
  604. .title {
  605. font-size: 16px;
  606. font-weight: 600;
  607. padding-left: 10px;
  608. }
  609. }
  610. .add {
  611. display: flex;
  612. align-items: center;
  613. justify-content: center;
  614. border: 1px solid #EBEEF5;
  615. border-top: none;
  616. height: 50px;
  617. }
  618. </style>