engin_form.vue 18 KB

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