engin_form.vue 33 KB

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