engin_form.vue 31 KB

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