engin_form.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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" :rules="mainFormRules" label-width="110px" size="small" label-position="right">
  8. <el-row :gutter="20">
  9. <el-col :xs="24" :sm="12" :lg="8">
  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="8" 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="8">
  27. <el-form-item label="产品大类" prop="mainId">
  28. <el-select v-model="mainForm.mainId" placeholder="选择产品大类" style="width: 100%">
  29. <el-option v-for="item in typeList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode"></el-option>
  30. </el-select>
  31. </el-form-item>
  32. </el-col> -->
  33. </el-row>
  34. <el-row :gutter="20">
  35. <el-col :xs="24" :sm="12" :lg="8">
  36. <el-form-item label="经销商编码" prop="jxsNum">
  37. <el-input v-model="mainForm.jxsNum" placeholder="请输入经销商编码" disabled></el-input>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :xs="24" :sm="12" :lg="8">
  41. <el-form-item label="项目名称" prop="enginName">
  42. <el-input v-model="mainForm.enginName" placeholder="请输入项目名称"></el-input>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :xs="24" :sm="12" :lg="8">
  46. <el-form-item label="单据类型" prop="orderType">
  47. <el-input v-model="mainForm.orderType" placeholder="请输入单据类型"></el-input>
  48. </el-form-item>
  49. </el-col>
  50. <el-col :xs="24" :sm="12" :lg="8">
  51. <el-form-item label="经销商名称" prop="jxsName">
  52. <el-input v-model="mainForm.jxsName" placeholder="请输入经销商名称" disabled></el-input>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :xs="24" :sm="12" :lg="8">
  56. <el-form-item label="使用单位" prop="company">
  57. <el-input v-model="mainForm.company" placeholder="请输入使用单位"></el-input>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :xs="24" :sm="12" :lg="8">
  61. <el-form-item label="安装地址" prop="address">
  62. <el-input v-model="mainForm.address" placeholder="请输入安装地址"></el-input>
  63. </el-form-item>
  64. </el-col>
  65. <el-col :xs="24" :sm="12" :lg="8">
  66. <el-form-item label="工程编号" prop="enginNum">
  67. <el-input v-model="mainForm.enginNum" placeholder="请输入工程编号"></el-input>
  68. </el-form-item>
  69. </el-col>
  70. <el-col :xs="24" :sm="12" :lg="8">
  71. <el-form-item label="厂工程编码" prop="factoryNum">
  72. <el-input v-model="mainForm.factoryNum" placeholder="请输入厂工程编码"></el-input>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :xs="24" :sm="12" :lg="8">
  76. <el-form-item label="工程登录类型" prop="loginType">
  77. <el-select v-model="mainForm.loginType" placeholder="选择工程登录类型" size="small" clearable style="width: 100%">
  78. <el-option
  79. v-for="item in loginTypeList"
  80. :key="item.value"
  81. :label="item.label"
  82. :value="item.value">
  83. </el-option>
  84. </el-select>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :xs="24" :sm="12" :lg="8">
  88. <el-form-item label="联系人" prop="linkman">
  89. <el-input v-model="mainForm.linkman" placeholder="请输入联系人"></el-input>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :xs="24" :sm="12" :lg="8">
  93. <el-form-item label="联系电话" prop="phone">
  94. <el-input v-model="mainForm.phone" placeholder="请输入联系电话"></el-input>
  95. </el-form-item>
  96. </el-col>
  97. <el-col :xs="24" :sm="12" :lg="8">
  98. <el-form-item label="固定电话" prop="tel">
  99. <el-input v-model="mainForm.tel" placeholder="请输入固定电话"></el-input>
  100. </el-form-item>
  101. </el-col>
  102. <el-col :xs="24" :sm="24" :lg="16">
  103. <el-form-item label="备注" prop="remark">
  104. <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
  105. </el-form-item>
  106. </el-col>
  107. <el-col :xs="24" :sm="12" :lg="8">
  108. <el-form-item label="业务员" prop="salesMan">
  109. <el-select v-model="mainForm.salesMan" placeholder="选择业务员" size="small" filterable clearable style="width: 100%">
  110. <el-option
  111. v-for="item in salesmanList"
  112. :key="item.adminUserId"
  113. :label="item.nickName"
  114. :value="item.adminUserId">
  115. </el-option>
  116. </el-select>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :xs="24" :sm="12" :lg="8">
  120. <el-form-item label="制单人" prop="createMan">
  121. <el-input v-model="mainForm.createMan" placeholder="请输入制单人" disabled></el-input>
  122. </el-form-item>
  123. </el-col>
  124. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  125. <el-form-item label="制单日期" prop="createDate">
  126. <el-date-picker
  127. v-model="mainForm.createDate"
  128. type="date"
  129. disabled
  130. value-format="yyyy-MM-dd"
  131. style="width: 100%;"
  132. placeholder="选择日期">
  133. </el-date-picker>
  134. </el-form-item>
  135. </el-col>
  136. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  137. <el-form-item label="合同有效期" prop="contractDate">
  138. <el-date-picker
  139. v-model="mainForm.contractDate"
  140. type="date"
  141. value-format="yyyy-MM-dd"
  142. style="width: 100%;"
  143. placeholder="选择日期">
  144. </el-date-picker>
  145. </el-form-item>
  146. </el-col>
  147. </el-row>
  148. </el-form>
  149. <div class="main-title">
  150. <div class="title">货品信息</div>
  151. </div>
  152. <div class="table" style="margin-top: 20px">
  153. <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
  154. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  155. <el-table-column align="center" label="销售类型" prop="saleTypeId" min-width="160" show-overflow-tooltip>
  156. <template slot-scope="scope">
  157. <el-select v-model="scope.row.saleTypeId" placeholder="选择销售类型" size="small" @change="changeSaleType(scope.$index)">
  158. <el-option
  159. v-for="item in salesTypeList"
  160. :key="item.id"
  161. :label="item.saleName"
  162. :value="item.id">
  163. </el-option>
  164. </el-select>
  165. </template>
  166. </el-table-column>
  167. <el-table-column align="center" label="产品名称" prop="materialNumber" min-width="160" show-overflow-tooltip>
  168. <template slot-scope="scope">
  169. <el-select v-model="scope.row.materialNumber" placeholder="选择产品" size="small" @change="changeGoods(scope.$index)" :disabled="!scope.row.saleTypeId">
  170. <el-option
  171. v-for="item in scope.row.productList"
  172. :key="item.number"
  173. :label="item.name"
  174. :value="item.number">
  175. </el-option>
  176. </el-select>
  177. </template>
  178. </el-table-column>
  179. <el-table-column align="center" label="产品编码" prop="materialNumber" min-width="120" show-overflow-tooltip></el-table-column>
  180. <el-table-column align="center" label="规格型号" prop="specification" min-width="200" show-overflow-tooltip></el-table-column>
  181. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
  182. <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip></el-table-column>
  183. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  184. <template slot-scope="scope">
  185. <el-input v-model="scope.row.qty" size="small" type="number"></el-input>
  186. </template>
  187. </el-table-column>
  188. <el-table-column align="center" label="订单金额" min-width="100" show-overflow-tooltip>
  189. <template slot-scope="scope">
  190. {{(scope.row.price || 0) * (scope.row.qty || 0)}}
  191. </template>
  192. </el-table-column>
  193. <el-table-column align="center" label="备注" prop="remark" min-width="200" show-overflow-tooltip>
  194. <template slot-scope="scope">
  195. <el-input v-model="scope.row.remark" size="small"></el-input>
  196. </template>
  197. </el-table-column>
  198. <el-table-column align="center" label="税率" prop="taxRate" min-width="100" show-overflow-tooltip></el-table-column>
  199. <el-table-column align="center" label="操作" width="100" fixed="right">
  200. <template slot-scope="scope">
  201. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  202. </template>
  203. </el-table-column>
  204. </el-table>
  205. <div class="add"><el-button type="text" icon="el-icon-plus" @click="addGoods">添加产品</el-button></div>
  206. </div>
  207. <div class="page-footer">
  208. <div class="footer">
  209. <el-button type="primary" @click="clickSubmitForm(1)">保 存</el-button>
  210. <el-button type="primary" @click="clickSubmitForm(2)">提交审核</el-button>
  211. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
  212. <el-button slot="reference">关 闭</el-button>
  213. </el-popconfirm>
  214. </div>
  215. </div>
  216. </div>
  217. </template>
  218. <script>
  219. import { getEnginDetail, getRetailProductList, addEngin, editEngin, submitEngin } from "@/api/supply/engin";
  220. import { getDictList, getTypeList, getSalesmanList } from '@/api/common'
  221. export default {
  222. name: 'EnginForm',
  223. componentName: 'EnginForm',
  224. props: ['listItem'],
  225. data() {
  226. return {
  227. goodsList: [],
  228. mainForm: {
  229. orderNum: '',
  230. orderDate: '',
  231. // mainId: '102',
  232. jxsNum: '',
  233. enginName: '',
  234. orderType: '',
  235. jxsName: '',
  236. company: '',
  237. address: '',
  238. enginNum: '',
  239. factoryNum: '',
  240. loginType: '',
  241. linkman: '',
  242. phone: '',
  243. tel: '',
  244. remark: '',
  245. salesMan: '',
  246. createMan: '',
  247. createDate: '',
  248. contractDate: '',
  249. },
  250. mainFormRules: {
  251. // orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
  252. jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
  253. enginName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
  254. jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
  255. company: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
  256. address: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
  257. loginType: [{ required: true, message: '请输入工程登录类型', trigger: 'blur' }],
  258. },
  259. loginTypeList: [
  260. {label: '工装登录', value: '工装登录'},
  261. {label: '家装登录', value: '家装登录'},
  262. {label: '跨区登录', value: '跨区登录'},
  263. ],
  264. typeList: [],
  265. salesTypeList: [],
  266. retailProductList: [],
  267. salesmanList: [],
  268. }
  269. },
  270. async created() {
  271. await this.getSalesmanList();
  272. this.getDictList();
  273. this.getTypeList();
  274. if(this.listItem) {
  275. this.getDetail();
  276. }else {
  277. this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerNumber;
  278. this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
  279. this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
  280. this.mainForm.createDate = this.getDate(0);
  281. this.mainForm.contractDate = this.getDate(1);
  282. }
  283. },
  284. methods: {
  285. // 返回列表
  286. goBack() {
  287. this.$emit('backListFormDetail');
  288. },
  289. getDate(addYear) {
  290. var date = new Date();
  291. var seperator1 = "-";
  292. var year = date.getFullYear() + addYear;
  293. var month = date.getMonth() + 1;
  294. var strDate = date.getDate();
  295. if (month >= 1 && month <= 9) {
  296. month = "0" + month;
  297. }
  298. if (strDate >= 0 && strDate <= 9) {
  299. strDate = "0" + strDate;
  300. }
  301. var currentdate = year + seperator1 + month + seperator1 + strDate;
  302. return currentdate;
  303. },
  304. // 获取详情
  305. getDetail() {
  306. getEnginDetail({id: this.listItem.enginInfoId}).then(res => {
  307. let data = res.data;
  308. this.mainForm.orderNum = data.enginInfoNo;
  309. this.mainForm.orderDate = data.orderDate;
  310. // this.mainForm.mainId = data.productCategoryId;
  311. this.mainForm.jxsNum = data.customerNumber;
  312. this.mainForm.enginName = data.projectName;
  313. this.mainForm.orderType = data.orderType;
  314. this.mainForm.jxsName = data.customerName;
  315. this.mainForm.company = data.useUnit;
  316. this.mainForm.address = data.installAddress;
  317. this.mainForm.enginNum = data.projectNo;
  318. this.mainForm.factoryNum = data.enginFactoryNo;
  319. this.mainForm.loginType = data.enginSignType;
  320. this.mainForm.linkman = data.linkman;
  321. this.mainForm.phone = data.phone;
  322. this.mainForm.tel = data.tel;
  323. this.mainForm.remark = data.remark;
  324. this.mainForm.salesMan = data.serviceId;
  325. this.mainForm.createMan = data.createName;
  326. this.mainForm.createDate = data.createTime;
  327. this.mainForm.contractDate = data.contractExpireDate;
  328. this.goodsList = data.items;
  329. for (let i = 0; i < this.goodsList.length; i++) {
  330. this.getRetailProductList(i);
  331. }
  332. })
  333. },
  334. // 获取产品大类列表
  335. getDictList() {
  336. getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
  337. this.typeList = res.data;
  338. })
  339. },
  340. // 获取销售类型列表
  341. getTypeList() {
  342. getTypeList({
  343. pageNum: 1,
  344. pageSize: -1,
  345. }).then((res) => {
  346. this.salesTypeList = res.data.records;
  347. });
  348. },
  349. async getSalesmanList() {
  350. const res = await getSalesmanList({
  351. pageNum: 1,
  352. pageSize: -1,
  353. isCustomer: 0,
  354. status: true,
  355. });
  356. this.salesmanList = res.data.records;
  357. },
  358. // 获取商品列表
  359. getRetailProductList(index) {
  360. getRetailProductList({
  361. pageNum: 1,
  362. pageSize: -1,
  363. saleId: this.goodsList[index].saleTypeId
  364. }).then(res => {
  365. let item = this.goodsList[index];
  366. item.productList = res.data.records;
  367. this.$set(this.goodsList, index, item);
  368. })
  369. },
  370. // 修改销售类型
  371. changeSaleType(index) {
  372. if(this.goodsList[index].saleTypeId) {
  373. let obj = this.salesTypeList.find(o => o.id == this.goodsList[index].saleTypeId);
  374. this.goodsList[index].saleTypeName = obj.saleName;
  375. this.goodsList[index].saleTypeCode = obj.saleCode;
  376. }
  377. this.goodsList[index].materialNumber = '';
  378. this.goodsList[index].materialName = '';
  379. this.goodsList[index].materialId = '';
  380. this.goodsList[index].specification = '';
  381. this.goodsList[index].unit = '';
  382. this.goodsList[index].price = '';
  383. this.goodsList[index].taxRate = '';
  384. this.getRetailProductList(index);
  385. },
  386. // 修改产品
  387. changeGoods(index) {
  388. if(this.goodsList[index].materialNumber) {
  389. let obj = this.goodsList[index].productList.find(o => o.number == this.goodsList[index].materialNumber);
  390. let item = this.goodsList[index];
  391. item.materialName = obj.name;
  392. item.materialId = obj.materialId;
  393. item.specification = obj.specification;
  394. item.unit = obj.unit;
  395. item.price = obj.batchPrice;
  396. item.taxRate = obj.taxRate;
  397. this.$set(this.goodsList, index, item);
  398. }
  399. },
  400. // 添加产品
  401. addGoods() {
  402. this.goodsList.push({})
  403. },
  404. // 删除产品
  405. deleteItem(index) {
  406. this.goodsList.splice(index, 1);
  407. },
  408. clickSubmitForm(type) {
  409. this.$refs.mainForm.validate((valid) => {
  410. if (valid) {
  411. for(let i=0; i<this.goodsList.length; i++) {
  412. if(!this.goodsList[i].saleTypeId) {
  413. this.$errorMsg('请选择销售类型');
  414. return;
  415. }
  416. if(!this.goodsList[i].materialNumber) {
  417. this.$errorMsg('请选择产品');
  418. return;
  419. }
  420. if(!this.goodsList[i].qty) {
  421. this.$errorMsg('请输入数量');
  422. return;
  423. }
  424. }
  425. let goodsList = JSON.parse(JSON.stringify(this.goodsList));
  426. goodsList.forEach(item => {
  427. delete item.productList;
  428. })
  429. let params = {
  430. // orderDate: this.mainForm.orderDate + ' 00:00:00',
  431. // mainId: this.mainForm.mainId,
  432. projectName: this.mainForm.enginName,
  433. orderType: this.mainForm.orderType,
  434. useUnit: this.mainForm.company,
  435. installAddress: this.mainForm.address,
  436. projectNo: this.mainForm.enginNum,
  437. enginFactoryNo: this.mainForm.factoryNum,
  438. enginSignType: this.mainForm.loginType,
  439. linkman: this.mainForm.linkman,
  440. phone: this.mainForm.phone,
  441. tel: this.mainForm.tel,
  442. remark: this.mainForm.remark,
  443. contractExpireDate: this.mainForm.contractDate,
  444. items: goodsList
  445. }
  446. if(type === 1) {
  447. if(this.listItem) {
  448. params.enginInfoId = this.listItem.enginInfoId;
  449. editEngin(params).then(res => {
  450. this.$successMsg('编辑成功');
  451. this.goBack();
  452. this.$parent.getList();
  453. })
  454. }else {
  455. addEngin(params).then(res => {
  456. this.$successMsg('保存成功');
  457. this.goBack();
  458. this.$parent.getList();
  459. })
  460. }
  461. }else {
  462. if(this.listItem) {
  463. params.enginInfoId = this.listItem.enginInfoId;
  464. }
  465. submitEngin(params).then(res => {
  466. this.$successMsg('提交审核成功');
  467. this.goBack();
  468. this.$parent.getList();
  469. })
  470. }
  471. }
  472. })
  473. },
  474. }
  475. }
  476. </script>
  477. <style scoped lang="scss">
  478. .detail-container {
  479. width: 100%;
  480. height: 100%;
  481. }
  482. .main-title {
  483. display: flex;
  484. justify-content: space-between;
  485. align-items: center;
  486. margin-top: 20px;
  487. height: 60px;
  488. border-bottom: 1px solid #DCDFE6;
  489. margin-bottom: 20px;
  490. .title {
  491. font-size: 16px;
  492. font-weight: 600;
  493. padding-left: 10px;
  494. }
  495. }
  496. .add {
  497. display: flex;
  498. align-items: center;
  499. justify-content: center;
  500. border: 1px solid #EBEEF5;
  501. border-top: none;
  502. height: 50px;
  503. }
  504. ::v-deep input::-webkit-outer-spin-button,
  505. ::v-deep input::-webkit-inner-spin-button {
  506. -webkit-appearance: none;
  507. }
  508. ::v-deep input[type='number'] {
  509. -moz-appearance: textfield;
  510. }
  511. </style>