engin_form.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  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. <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog">添加货品</el-button>
  153. </div>
  154. </div>
  155. <div class="table" style="margin-top: 20px">
  156. <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
  157. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  158. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="120" show-overflow-tooltip></el-table-column>
  159. <el-table-column align="center" label="物料编码" prop="materialNumber" min-width="120" show-overflow-tooltip></el-table-column>
  160. <el-table-column align="center" label="产品编码" prop="materialOldNumber" min-width="120" show-overflow-tooltip></el-table-column>
  161. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  162. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip>
  163. <template slot-scope="scope">
  164. <el-input v-model="scope.row.specification" size="small" v-if="listItem"></el-input>
  165. <div v-else>{{scope.row.specification}}</div>
  166. </template>
  167. </el-table-column>
  168. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
  169. <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
  170. <template slot-scope="scope">
  171. <el-input v-model="scope.row.price" size="small" type="number"></el-input>
  172. </template>
  173. </el-table-column>
  174. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  175. <template slot-scope="scope">
  176. <el-input v-model="scope.row.qty" size="small" type="number"></el-input>
  177. </template>
  178. </el-table-column>
  179. <el-table-column align="center" label="订单金额" min-width="100" show-overflow-tooltip>
  180. <template slot-scope="scope">
  181. {{(scope.row.price || 0) * (scope.row.qty || 0)}}
  182. </template>
  183. </el-table-column>
  184. <el-table-column align="center" label="备注" prop="remark" min-width="200" show-overflow-tooltip>
  185. <template slot-scope="scope">
  186. <el-input v-model="scope.row.remark" size="small"></el-input>
  187. </template>
  188. </el-table-column>
  189. <el-table-column align="center" label="税率" prop="taxRate" min-width="100" show-overflow-tooltip></el-table-column>
  190. <el-table-column align="center" label="操作" width="100" fixed="right">
  191. <template slot-scope="scope">
  192. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  193. </template>
  194. </el-table-column>
  195. </el-table>
  196. </div>
  197. <div class="page-footer">
  198. <div class="footer">
  199. <el-button type="primary" @click="clickSubmitForm(1)">保 存</el-button>
  200. <el-button type="primary" @click="clickSubmitForm(2)">提交审核</el-button>
  201. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
  202. <el-button slot="reference">关 闭</el-button>
  203. </el-popconfirm>
  204. </div>
  205. </div>
  206. <el-dialog title="添加产品" :visible.sync="isShowGoodsDialog" width="80%">
  207. <el-form ref="goodsScreenForm" :model="goodsScreenForm" size="small" label-position="left">
  208. <el-row :gutter="20">
  209. <el-col :xs="12" :sm="6" :lg="6">
  210. <el-form-item prop="salesType">
  211. <el-select v-model="goodsScreenForm.salesType" placeholder="选择销售类型" style="width: 100%" clearable>
  212. <el-option v-for="item in salesTypeList" :key="item.id" :label="item.saleName" :value="item.id"></el-option>
  213. </el-select>
  214. </el-form-item>
  215. </el-col>
  216. <el-col :xs="12" :sm="6" :lg="6">
  217. <el-form-item prop="proNum">
  218. <el-input v-model="goodsScreenForm.proNum" placeholder="请输入产品编码"></el-input>
  219. </el-form-item>
  220. </el-col>
  221. <el-col :xs="12" :sm="6" :lg="6">
  222. <el-form-item prop="proName">
  223. <el-input v-model="goodsScreenForm.proName" placeholder="请输入产品名称"></el-input>
  224. </el-form-item>
  225. </el-col>
  226. <el-col :xs="12" :sm="6" :lg="6">
  227. <el-form-item prop="proModel">
  228. <el-input v-model="goodsScreenForm.proModel" placeholder="请输入产品型号"></el-input>
  229. </el-form-item>
  230. </el-col>
  231. <el-col :xs="12" :sm="6" :lg="6">
  232. <el-form-item prop="price1" style="display: flex">
  233. <el-input v-model="goodsScreenForm.price1" placeholder="请输入价格" style="width: 46%"></el-input>
  234. <span> - </span>
  235. <el-input v-model="goodsScreenForm.price2" placeholder="请输入价格" style="width: 46%"></el-input>
  236. </el-form-item>
  237. </el-col>
  238. <el-col :xs="12" :sm="18" :lg="18" class="tr">
  239. <el-form-item label="">
  240. <el-button size="small" @click="resetGoodsScreenForm">清空</el-button>
  241. <el-button size="small" type="primary" @click="submitGoodsScreenForm">搜索</el-button>
  242. </el-form-item>
  243. </el-col>
  244. </el-row>
  245. </el-form>
  246. <div class="tables">
  247. <div class="table">
  248. <el-table :data="leftGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="leftSelectionChange">
  249. <el-table-column align="center" type="selection" width="55" :selectable='checkboxSelect'></el-table-column>
  250. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
  251. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  252. <el-table-column align="center" label="产品型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  253. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip></el-table-column>
  254. </el-table>
  255. <div class="pagination clearfix" style="margin-top: 10px">
  256. <div class="fr">
  257. <el-pagination
  258. @current-change="handleTableCurrentChange"
  259. :current-page="currentPage"
  260. :page-size="10"
  261. background
  262. layout="prev, pager, next"
  263. :total="listTotal">
  264. </el-pagination>
  265. </div>
  266. </div>
  267. </div>
  268. <div class="buttons">
  269. <el-button size="small" type="primary" @click="addAllGoods">全部添加</el-button>
  270. <el-button size="small" type="primary" @click="addGoods">添&emsp;加</el-button>
  271. <el-button size="small" type="danger" @click="deleteGoods">删&emsp;除</el-button>
  272. <el-button size="small" type="danger" @click="deleteAllGoods">全部删除</el-button>
  273. </div>
  274. <div class="table">
  275. <el-table :data="rightGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="rightSelectionChange">
  276. <el-table-column align="center" type="selection" width="55"></el-table-column>
  277. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
  278. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  279. <el-table-column align="center" label="产品型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  280. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip></el-table-column>
  281. </el-table>
  282. </div>
  283. </div>
  284. <span slot="footer" class="dialog-footer">
  285. <el-button @click="closeDialog">取 消</el-button>
  286. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  287. </span>
  288. </el-dialog>
  289. </div>
  290. </template>
  291. <script>
  292. import { getEnginDetail, getRetailProductList, addEngin, editEngin, submitEngin } from "@/api/supply/engin";
  293. import { getDictList, getTypeList, getSalesmanList } from '@/api/common'
  294. export default {
  295. name: 'EnginForm',
  296. componentName: 'EnginForm',
  297. props: ['listItem'],
  298. data() {
  299. return {
  300. goodsList: [],
  301. mainForm: {
  302. orderNum: '',
  303. orderDate: '',
  304. // mainId: '102',
  305. jxsNum: '',
  306. enginName: '',
  307. orderType: '',
  308. jxsName: '',
  309. company: '',
  310. address: '',
  311. enginNum: '',
  312. factoryNum: '',
  313. loginType: '',
  314. linkman: '',
  315. phone: '',
  316. tel: '',
  317. remark: '',
  318. salesMan: '',
  319. createMan: '',
  320. createDate: '',
  321. contractDate: '',
  322. },
  323. mainFormRules: {
  324. // orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
  325. jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
  326. enginName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
  327. jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
  328. company: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
  329. address: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
  330. loginType: [{ required: true, message: '请输入工程登录类型', trigger: 'blur' }],
  331. },
  332. loginTypeList: [
  333. {label: '工装登录', value: '工装登录'},
  334. {label: '家装登录', value: '家装登录'},
  335. {label: '跨区登录', value: '跨区登录'},
  336. ],
  337. typeList: [],
  338. salesTypeList: [],
  339. salesmanList: [],
  340. isShowGoodsDialog: false,
  341. goodsScreenForm: {
  342. proNum: '',
  343. proName: '',
  344. proModel: '',
  345. price1: '',
  346. price2: '',
  347. salesType: '',
  348. },
  349. currentPage: 1,
  350. listTotal: 0,
  351. leftGoodsList: [],
  352. rightGoodsList: [],
  353. leftSelection: [],
  354. rightSelection: [],
  355. }
  356. },
  357. async created() {
  358. await this.getSalesmanList();
  359. this.getDictList();
  360. this.getTypeList();
  361. if(this.listItem) {
  362. this.getDetail();
  363. }else {
  364. this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerNumber;
  365. this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
  366. this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
  367. this.mainForm.createDate = this.getDate(0);
  368. this.mainForm.contractDate = this.getDate(1);
  369. }
  370. },
  371. methods: {
  372. // 返回列表
  373. goBack() {
  374. this.$emit('backListFormDetail');
  375. },
  376. getDate(addYear) {
  377. var date = new Date();
  378. var seperator1 = "-";
  379. var year = date.getFullYear() + addYear;
  380. var month = date.getMonth() + 1;
  381. var strDate = date.getDate();
  382. if (month >= 1 && month <= 9) {
  383. month = "0" + month;
  384. }
  385. if (strDate >= 0 && strDate <= 9) {
  386. strDate = "0" + strDate;
  387. }
  388. var currentdate = year + seperator1 + month + seperator1 + strDate;
  389. return currentdate;
  390. },
  391. // 获取详情
  392. getDetail() {
  393. getEnginDetail({id: this.listItem.enginInfoId}).then(res => {
  394. let data = res.data;
  395. this.mainForm.orderNum = data.enginInfoNo;
  396. this.mainForm.orderDate = data.orderDate;
  397. // this.mainForm.mainId = data.productCategoryId;
  398. this.mainForm.jxsNum = data.customerNumber;
  399. this.mainForm.enginName = data.projectName;
  400. this.mainForm.orderType = data.orderType;
  401. this.mainForm.jxsName = data.customerName;
  402. this.mainForm.company = data.useUnit;
  403. this.mainForm.address = data.installAddress;
  404. this.mainForm.enginNum = data.projectNo;
  405. this.mainForm.factoryNum = data.enginFactoryNo;
  406. this.mainForm.loginType = data.enginSignType;
  407. this.mainForm.linkman = data.linkman;
  408. this.mainForm.phone = data.phone;
  409. this.mainForm.tel = data.tel;
  410. this.mainForm.remark = data.remark;
  411. this.mainForm.salesMan = data.serviceId;
  412. this.mainForm.createMan = data.createName;
  413. this.mainForm.createDate = data.createTime;
  414. this.mainForm.contractDate = data.contractExpireDate;
  415. this.goodsList = data.items;
  416. })
  417. },
  418. // 获取产品大类列表
  419. getDictList() {
  420. getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
  421. this.typeList = res.data;
  422. })
  423. },
  424. // 获取销售类型列表
  425. getTypeList() {
  426. getTypeList({
  427. pageNum: 1,
  428. pageSize: -1,
  429. }).then((res) => {
  430. this.salesTypeList = res.data.records;
  431. });
  432. },
  433. async getSalesmanList() {
  434. const res = await getSalesmanList({
  435. pageNum: 1,
  436. pageSize: -1,
  437. isCustomer: 0,
  438. status: true,
  439. });
  440. this.salesmanList = res.data.records;
  441. },
  442. // 获取商品列表
  443. getGoodsList() {
  444. getRetailProductList({
  445. pageNum: this.currentPage,
  446. pageSize: 10,
  447. saleId: this.goodsScreenForm.salesType,
  448. materialCode: this.goodsScreenForm.proNum,
  449. materialName: this.goodsScreenForm.proName,
  450. specification: this.goodsScreenForm.proModel,
  451. price1: this.goodsScreenForm.price1,
  452. price2: this.goodsScreenForm.price2,
  453. }).then(res => {
  454. let oldGoodsList = this.goodsList;
  455. let newGoodsList = res.data.records;
  456. for(let i = 0; i < oldGoodsList.length; i++) {
  457. let oldItem = oldGoodsList[i]
  458. for(let j = 0; j < newGoodsList.length; j++) {
  459. let newItem = newGoodsList[j]
  460. if(newItem.id === oldItem.id){
  461. newGoodsList[j].selected = true;
  462. break;
  463. }
  464. }
  465. }
  466. res.data.records.forEach(item => {
  467. item.materialName = item.name;
  468. item.materialCode = item.number;
  469. item.saleTypeName = item.saleName;
  470. item.unit = item.baseUnit;
  471. item.price = item.batchPrice;
  472. item.tax = item.taxRate;
  473. item.isDirectTransfer = false;
  474. item.directTransferQty = '';
  475. item.status1 = '';
  476. item.status2 = '';
  477. item.rebateAmount = '';
  478. item.rebateRate = '';
  479. item.productPriceId = item.id;
  480. // item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
  481. });
  482. this.leftGoodsList = res.data.records;
  483. this.listTotal = res.data.total;
  484. })
  485. },
  486. // 查询重复值并禁选
  487. checkboxSelect(row, rowIndex) {
  488. if (row.selected) {
  489. return false // 禁用
  490. }else{
  491. return true // 不禁用
  492. }
  493. },
  494. // 点击 选择商品
  495. openDialog() {
  496. this.isShowGoodsDialog = true;
  497. this.getGoodsList();
  498. },
  499. // 提交筛选表单
  500. submitGoodsScreenForm() {
  501. this.currentPage = 1;
  502. this.getGoodsList();
  503. },
  504. // 重置筛选表单
  505. resetGoodsScreenForm() {
  506. this.$refs.goodsScreenForm.resetFields();
  507. this.currentPage = 1;
  508. this.getGoodsList();
  509. },
  510. // 更改列表当前页
  511. handleTableCurrentChange(val) {
  512. this.currentPage = val;
  513. this.getGoodsList();
  514. },
  515. // 关闭 弹窗
  516. closeDialog() {
  517. this.isShowGoodsDialog = false;
  518. },
  519. // 左侧列表选择
  520. leftSelectionChange(val) {
  521. this.leftSelection = val;
  522. },
  523. // 右侧列表选择
  524. rightSelectionChange(val) {
  525. this.rightSelection = val;
  526. },
  527. // 数组去重
  528. delRepeat(arr1, arr2) {
  529. let allArr = arr1.concat(arr2); // 两个数组对象合并
  530. let newArr = []; // 存放去重后数据的新数组
  531. for(let i=0; i<allArr.length; i++){ // 循环allArr数组对象的内容
  532. let flag = true; // 建立标记,判断数据是否重复,true为不重复
  533. for(let j=0; j<newArr.length; j++){ // 循环新数组的内容
  534. if(allArr[i].id == newArr[j].id){ // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  535. flag = false;
  536. }
  537. }
  538. if(flag){ // 判断是否重复
  539. newArr.push(allArr[i]); // 不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  540. }
  541. }
  542. return newArr;
  543. },
  544. // 全部添加
  545. addAllGoods() {
  546. this.rightGoodsList = this.delRepeat(this.leftGoodsList, this.rightGoodsList);
  547. },
  548. // 添加
  549. addGoods() {
  550. this.rightGoodsList = this.delRepeat(this.leftSelection, this.rightGoodsList);
  551. },
  552. // 删除
  553. deleteGoods() {
  554. let rightGoodsList = this.rightGoodsList;
  555. let rightSelection = this.rightSelection;
  556. for(let i = 0; i < rightGoodsList.length; i++) {
  557. for(let j = 0; j < rightSelection.length; j++) {
  558. if(rightSelection[j].materialId == rightGoodsList[i].materialId){
  559. this.rightGoodsList.splice(i, 1);
  560. }
  561. }
  562. }
  563. },
  564. // 全部删除
  565. deleteAllGoods() {
  566. this.rightGoodsList = [];
  567. },
  568. // 确定 添加产品
  569. submitAddGoods() {
  570. // this.goodsList = this.delRepeat(this.rightGoodsList, this.goodsList);
  571. this.goodsList = this.goodsList.concat(this.rightGoodsList);
  572. this.isShowGoodsDialog = false;
  573. this.leftGoodsList = [];
  574. this.rightGoodsList = [];
  575. },
  576. // 删除产品
  577. deleteItem(index) {
  578. this.goodsList.splice(index, 1);
  579. },
  580. clickSubmitForm(type) {
  581. this.$refs.mainForm.validate((valid) => {
  582. if (valid) {
  583. for(let i=0; i<this.goodsList.length; i++) {
  584. if(!this.goodsList[i].saleTypeId) {
  585. this.$errorMsg('请选择销售类型');
  586. return;
  587. }
  588. if(!this.goodsList[i].materialNumber) {
  589. this.$errorMsg('请选择产品');
  590. return;
  591. }
  592. if(!this.goodsList[i].qty) {
  593. this.$errorMsg('请输入数量');
  594. return;
  595. }
  596. }
  597. let goodsList = JSON.parse(JSON.stringify(this.goodsList));
  598. goodsList.forEach(item => {
  599. delete item.productList;
  600. delete item.id;
  601. })
  602. let saleManItem = this.mainForm.salesMan ? this.salesmanList.find(o => o.adminUserId == this.mainForm.salesMan) : '';
  603. let params = {
  604. // orderDate: this.mainForm.orderDate + ' 00:00:00',
  605. // mainId: this.mainForm.mainId,
  606. projectName: this.mainForm.enginName,
  607. orderType: this.mainForm.orderType,
  608. useUnit: this.mainForm.company,
  609. installAddress: this.mainForm.address,
  610. projectNo: this.mainForm.enginNum,
  611. enginFactoryNo: this.mainForm.factoryNum,
  612. enginSignType: this.mainForm.loginType,
  613. linkman: this.mainForm.linkman,
  614. phone: this.mainForm.phone,
  615. serviceId: this.mainForm.salesMan,
  616. serviceName: saleManItem.nickName,
  617. tel: this.mainForm.tel,
  618. remark: this.mainForm.remark,
  619. contractExpireDate: this.mainForm.contractDate,
  620. items: goodsList
  621. }
  622. if(type === 1) {
  623. if(this.listItem) {
  624. params.enginInfoId = this.listItem.enginInfoId;
  625. editEngin(params).then(res => {
  626. this.$successMsg('编辑成功');
  627. this.goBack();
  628. this.$parent.getList();
  629. })
  630. }else {
  631. addEngin(params).then(res => {
  632. this.$successMsg('保存成功');
  633. this.goBack();
  634. this.$parent.getList();
  635. })
  636. }
  637. }else {
  638. if(this.listItem) {
  639. params.enginInfoId = this.listItem.enginInfoId;
  640. }
  641. submitEngin(params).then(res => {
  642. this.$successMsg('提交审核成功');
  643. this.goBack();
  644. this.$parent.getList();
  645. })
  646. }
  647. }
  648. })
  649. },
  650. }
  651. }
  652. </script>
  653. <style scoped lang="scss">
  654. .detail-container {
  655. width: 100%;
  656. height: 100%;
  657. }
  658. .main-title {
  659. display: flex;
  660. justify-content: space-between;
  661. align-items: center;
  662. margin-top: 20px;
  663. height: 60px;
  664. border-bottom: 1px solid #DCDFE6;
  665. margin-bottom: 20px;
  666. .title {
  667. font-size: 16px;
  668. font-weight: 600;
  669. padding-left: 10px;
  670. }
  671. }
  672. .tables {
  673. display: flex;
  674. margin-top: 10px;
  675. .table {
  676. width: 45%;
  677. }
  678. .buttons {
  679. display: flex;
  680. flex-direction: column;
  681. justify-content: center;
  682. align-items: center;
  683. padding: 0 10px;
  684. button {
  685. margin: 0;
  686. margin-top: 10px;
  687. }
  688. }
  689. }
  690. ::v-deep input::-webkit-outer-spin-button,
  691. ::v-deep input::-webkit-inner-spin-button {
  692. -webkit-appearance: none;
  693. }
  694. ::v-deep input[type='number'] {
  695. -moz-appearance: textfield;
  696. }
  697. </style>