engin_form.vue 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header :content="listItem ? '编辑' : '新增'" @back="goBack" />
  4. <div class="main-title">
  5. <div class="title">工程信息单</div>
  6. </div>
  7. <el-form
  8. ref="mainForm"
  9. :model="mainForm"
  10. :rules="mainFormRules"
  11. label-width="110px"
  12. size="small"
  13. label-position="right"
  14. >
  15. <el-row :gutter="20">
  16. <el-col :xs="24" :sm="12" :lg="8">
  17. <el-form-item label="工程登录编号" prop="orderNum">
  18. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" disabled />
  19. </el-form-item>
  20. </el-col>
  21. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  22. <el-form-item label="单据日期" prop="orderDate">
  23. <el-date-picker
  24. v-model="mainForm.orderDate"
  25. disabled
  26. type="date"
  27. value-format="yyyy-MM-dd"
  28. style="width: 100%"
  29. placeholder="系统自动生成"
  30. />
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :sm="12" :lg="8">
  34. <el-form-item label="业务员" prop="salesMan">
  35. <el-select
  36. v-model="mainForm.salesMan"
  37. placeholder="选择业务员"
  38. size="small"
  39. filterable
  40. clearable
  41. style="width: 100%"
  42. >
  43. <el-option
  44. v-for="item in salesmanList"
  45. :key="item.adminUserId"
  46. :label="item.nickName"
  47. :value="item.adminUserId"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. </el-col>
  52. <!-- <el-col :xs="24" :sm="12" :lg="8">
  53. <el-form-item label="产品大类" prop="mainId">
  54. <el-select v-model="mainForm.mainId" placeholder="选择产品大类" style="width: 100%">
  55. <el-option v-for="item in typeList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode"></el-option>
  56. </el-select>
  57. </el-form-item>
  58. </el-col> -->
  59. </el-row>
  60. <el-row :gutter="20">
  61. <el-col :xs="24" :sm="12" :lg="8">
  62. <el-form-item label="经销商编码" prop="jxsNum">
  63. <el-input v-model="mainForm.jxsNum" placeholder="选择经销商" disabled />
  64. </el-form-item>
  65. </el-col>
  66. <el-col :xs="24" :sm="12" :lg="8">
  67. <el-form-item label="项目名称" prop="enginName">
  68. <el-input v-model="mainForm.enginName" placeholder="请输入项目名称" />
  69. </el-form-item>
  70. </el-col>
  71. <el-col :xs="24" :sm="12" :lg="8">
  72. <el-form-item label="机型类别" prop="machineType">
  73. <el-select
  74. v-model="mainForm.machineType"
  75. placeholder="选择机型类别"
  76. size="small"
  77. clearable
  78. style="width: 100%"
  79. >
  80. <el-option
  81. v-for="item in machineTypeList"
  82. :key="item.dictCode"
  83. :label="item.dictValue"
  84. :value="item.dictCode"
  85. />
  86. </el-select>
  87. </el-form-item>
  88. </el-col>
  89. <el-col :xs="24" :sm="12" :lg="8">
  90. <el-form-item label="经销商名称" prop="jxsNum">
  91. <el-select
  92. v-model="mainForm.jxsNum"
  93. placeholder="选择经销商"
  94. size="small"
  95. filterable
  96. clearable
  97. style="width: 100%"
  98. :disabled="listItem != undefined"
  99. @change="changeDealer"
  100. >
  101. <el-option v-for="item in dealerList" :key="item.number" :label="item.name" :value="item.number" />
  102. </el-select>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :xs="24" :sm="12" :lg="8">
  106. <el-form-item label="使用单位" prop="company">
  107. <el-input v-model="mainForm.company" placeholder="请输入使用单位" />
  108. </el-form-item>
  109. </el-col>
  110. <el-col :xs="24" :sm="12" :lg="8">
  111. <el-form-item label="行业类别" prop="tradeCategory">
  112. <el-select
  113. v-model="mainForm.tradeCategory"
  114. placeholder="选择行业类别"
  115. size="small"
  116. clearable
  117. style="width: 100%"
  118. >
  119. <el-option v-for="item in tradeCategoryList" :key="item.value" :label="item.label" :value="item.value" />
  120. </el-select>
  121. </el-form-item>
  122. </el-col>
  123. <el-col :xs="24" :sm="12" :lg="8">
  124. <el-form-item label="工程编号" prop="enginNum">
  125. <div style="display: flex">
  126. <el-input v-model="mainForm.enginNum" placeholder="请输入工程编号" />
  127. <el-button style="margin-left: 10px" @click="visible = true;getLoginOrderList()">引用</el-button>
  128. </div>
  129. </el-form-item>
  130. </el-col>
  131. <el-col :xs="24" :sm="12" :lg="8">
  132. <el-form-item label="厂工程编码" prop="factoryNum">
  133. <el-input v-model="mainForm.factoryNum" placeholder="请输入厂工程编码" />
  134. </el-form-item>
  135. </el-col>
  136. <el-col :xs="24" :sm="12" :lg="8">
  137. <el-form-item label="工程登录类型" prop="loginType">
  138. <el-select
  139. v-model="mainForm.loginType"
  140. placeholder="选择工程登录类型"
  141. size="small"
  142. clearable
  143. style="width: 100%"
  144. >
  145. <el-option
  146. v-for="item in loginTypeList"
  147. :key="item.dictCode"
  148. :label="item.dictValue"
  149. :value="item.dictCode"
  150. />
  151. </el-select>
  152. </el-form-item>
  153. </el-col>
  154. <el-col :xs="24" :sm="12" :lg="8">
  155. <el-form-item label="联系人" prop="linkman">
  156. <el-input v-model="mainForm.linkman" placeholder="请输入联系人" />
  157. </el-form-item>
  158. </el-col>
  159. <el-col :xs="24" :sm="12" :lg="8">
  160. <el-form-item label="联系电话" prop="phone">
  161. <el-input v-model="mainForm.phone" placeholder="请输入联系电话" />
  162. </el-form-item>
  163. </el-col>
  164. <el-col :xs="24" :sm="12" :lg="8">
  165. <el-form-item label="固定电话" prop="tel">
  166. <el-input v-model="mainForm.tel" placeholder="请输入固定电话" />
  167. </el-form-item>
  168. </el-col>
  169. <el-col :xs="24" :sm="16" :lg="16">
  170. <el-form-item label="安装地址" prop="address">
  171. <el-input v-model="mainForm.address" placeholder="请输入安装地址" />
  172. </el-form-item>
  173. </el-col>
  174. <el-col :xs="24" :sm="8" :lg="8">
  175. <el-form-item label="文件编号" prop="fileNo">
  176. <el-input v-model="mainForm.fileNo" placeholder="请输入文件编号" />
  177. </el-form-item>
  178. </el-col>
  179. <el-col v-if="!isDealer" :xs="24" :sm="24" :lg="16">
  180. <el-form-item label="格力内部备注" prop="greeRemark">
  181. <el-input v-model="mainForm.greeRemark" placeholder="请输入格力内部备注" />
  182. </el-form-item>
  183. </el-col>
  184. <el-col v-if="!isDealer" :xs="24" :sm="12" :lg="8">
  185. <el-form-item label="权限分类" prop="power">
  186. <el-select v-model="mainForm.power" placeholder="选择权限分类" size="small" clearable style="width: 100%">
  187. <el-option
  188. v-for="item in powerList"
  189. :key="item.dictCode"
  190. :label="item.dictValue"
  191. :value="item.dictCode"
  192. />
  193. </el-select>
  194. </el-form-item>
  195. </el-col>
  196. <el-col :xs="24" :sm="24" :lg="24">
  197. <el-form-item label="格力回复" prop="greeReply">
  198. <el-input
  199. v-model="mainForm.greeReply"
  200. :placeholder="isDealer ? '' : '请输入格力回复'"
  201. :disabled="isDealer"
  202. />
  203. </el-form-item>
  204. </el-col>
  205. <el-col :xs="24" :sm="24" :lg="24">
  206. <el-form-item label="备注" prop="remark">
  207. <el-input v-model="mainForm.remark" placeholder="请输入备注" />
  208. </el-form-item>
  209. </el-col>
  210. <el-col :xs="24" :sm="12" :lg="8">
  211. <el-form-item label="制单人" prop="createMan">
  212. <el-input v-model="mainForm.createMan" placeholder="请输入制单人" disabled />
  213. </el-form-item>
  214. </el-col>
  215. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  216. <el-form-item label="制单日期" prop="createDate">
  217. <el-date-picker
  218. v-model="mainForm.createDate"
  219. type="date"
  220. disabled
  221. value-format="yyyy-MM-dd"
  222. style="width: 100%"
  223. placeholder="选择日期"
  224. />
  225. </el-form-item>
  226. </el-col>
  227. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  228. <el-form-item label="合同有效期" prop="contractDate">
  229. <el-date-picker
  230. v-model="mainForm.contractDate"
  231. type="date"
  232. value-format="yyyy-MM-dd"
  233. style="width: 100%"
  234. placeholder="选择日期"
  235. />
  236. </el-form-item>
  237. </el-col>
  238. </el-row>
  239. </el-form>
  240. <div class="main-title">
  241. <div class="title">货品信息</div>
  242. <div>
  243. <el-button type="primary" size="mini" icon="el-icon-plus" @click="openDialog">添加货品</el-button>
  244. <el-divider direction="vertical" />
  245. <!-- <ImportButton :imUrl="'engin-info-order/import-item'" @importSuccess="getImportList" :isIcon="false" style="display: inline-block" />
  246. <ExportButton :exUrl="'engin-info-order/download'" :exParams="{}" :exText="'下载导入模版'" :isIcon="false" style="display: inline-block" /> -->
  247. </div>
  248. </div>
  249. <div class="table" style="margin-top: 20px">
  250. <el-table
  251. :data="goodsList"
  252. element-loading-text="Loading"
  253. border
  254. fit
  255. highlight-current-row
  256. stripe
  257. show-summary
  258. :summary-method="$getSummaries"
  259. max-height="400"
  260. >
  261. <el-table-column align="center" label="序号" type="index" width="50" />
  262. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="120" show-overflow-tooltip>
  263. <template slot-scope="scope">
  264. <el-select
  265. v-if="listItem"
  266. v-model="scope.row.saleTypeId"
  267. placeholder="选择销售类型"
  268. size="mini"
  269. clearable
  270. style="width: 100%"
  271. @change="changeSaleType(scope.$index)"
  272. >
  273. <el-option v-for="item in salesTypeList" :key="item.id" :label="item.saleName" :value="item.id" />
  274. </el-select>
  275. <div v-else>{{ scope.row.saleTypeName }}</div>
  276. </template>
  277. </el-table-column>
  278. <el-table-column align="center" label="物料编码" prop="materialNumber" min-width="120" show-overflow-tooltip />
  279. <el-table-column
  280. align="center"
  281. label="产品编码"
  282. prop="materialOldNumber"
  283. min-width="120"
  284. show-overflow-tooltip
  285. />
  286. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip />
  287. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip>
  288. <template slot-scope="scope">
  289. <el-input v-if="listItem" v-model="scope.row.specification" size="mini" />
  290. <div v-else>{{ scope.row.specification }}</div>
  291. </template>
  292. </el-table-column>
  293. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip />
  294. <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
  295. <template slot-scope="scope">
  296. <el-input v-model="scope.row.price" size="small" type="number" @mousewheel.native.prevent />
  297. </template>
  298. </el-table-column>
  299. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  300. <template slot-scope="scope">
  301. <el-input v-model.number="scope.row.qty" size="small" type="number" @mousewheel.native.prevent />
  302. </template>
  303. </el-table-column>
  304. <el-table-column align="center" label="订单金额" prop="myTotalAmount" min-width="100" show-overflow-tooltip>
  305. <template slot-scope="scope">
  306. {{ (scope.row.price || 0) * (scope.row.qty || 0) }}
  307. </template>
  308. </el-table-column>
  309. <el-table-column align="center" label="备注" prop="remark" min-width="200" show-overflow-tooltip>
  310. <template slot-scope="scope">
  311. <el-input v-model="scope.row.remark" size="small" />
  312. </template>
  313. </el-table-column>
  314. <el-table-column align="center" label="税率" prop="taxRate" min-width="100" show-overflow-tooltip />
  315. <el-table-column align="center" label="操作" width="100" fixed="right">
  316. <template slot-scope="scope">
  317. <el-button type="text" @click="deleteItem(scope.$index, scope.row, scope.row.cid)">删除</el-button>
  318. </template>
  319. </el-table-column>
  320. </el-table>
  321. </div>
  322. <div class="page-footer">
  323. <div class="footer">
  324. <el-button type="primary" :loading="btnLoading" @click="clickSubmitForm(1)">保 存</el-button>
  325. <!-- <el-button type="primary" @click="clickSubmitForm(2)">提交审核</el-button>-->
  326. <el-popconfirm title="确定关闭吗?" style="margin-left: 10px" @onConfirm="goBack">
  327. <el-button slot="reference">返回列表</el-button>
  328. </el-popconfirm>
  329. </div>
  330. </div>
  331. <el-dialog
  332. title="添加产品"
  333. :modal-append-to-body="true"
  334. :append-to-body="true"
  335. :visible.sync="isShowGoodsDialog"
  336. width="80%"
  337. >
  338. <el-form ref="goodsScreenForm" :model="goodsScreenForm" size="small" label-position="left">
  339. <el-row :gutter="20">
  340. <el-col :xs="12" :sm="6" :lg="6">
  341. <el-form-item prop="salesType">
  342. <el-select v-model="goodsScreenForm.salesType" placeholder="选择销售类型" style="width: 100%" clearable>
  343. <el-option v-for="item in salesTypeList" :key="item.id" :label="item.saleName" :value="item.id" />
  344. </el-select>
  345. </el-form-item>
  346. </el-col>
  347. <el-col :xs="12" :sm="6" :lg="6">
  348. <el-form-item prop="proNum">
  349. <el-input v-model="goodsScreenForm.proNum" placeholder="请输入产品编码" />
  350. </el-form-item>
  351. </el-col>
  352. <el-col :xs="12" :sm="6" :lg="6">
  353. <el-form-item prop="proName">
  354. <el-input v-model="goodsScreenForm.proName" placeholder="请输入产品名称" />
  355. </el-form-item>
  356. </el-col>
  357. <el-col :xs="12" :sm="6" :lg="6">
  358. <el-form-item prop="proModel">
  359. <el-input v-model="goodsScreenForm.proModel" placeholder="请输入产品型号" />
  360. </el-form-item>
  361. </el-col>
  362. <el-col :xs="12" :sm="6" :lg="6">
  363. <el-form-item prop="price1" style="display: flex">
  364. <el-input v-model="goodsScreenForm.price1" placeholder="请输入价格" style="width: 46%" />
  365. <span> - </span>
  366. <el-input v-model="goodsScreenForm.price2" placeholder="请输入价格" style="width: 46%" />
  367. </el-form-item>
  368. </el-col>
  369. <el-col :xs="12" :sm="18" :lg="18" class="tr">
  370. <el-form-item label="">
  371. <el-button size="small" @click="resetGoodsScreenForm">清空</el-button>
  372. <el-button size="small" type="primary" @click="submitGoodsScreenForm">搜索</el-button>
  373. </el-form-item>
  374. </el-col>
  375. </el-row>
  376. </el-form>
  377. <div class="tables">
  378. <div class="table">
  379. <el-table
  380. :data="leftGoodsList"
  381. element-loading-text="Loading"
  382. border
  383. fit
  384. highlight-current-row
  385. stripe
  386. height="400"
  387. @selection-change="leftSelectionChange"
  388. >
  389. <el-table-column align="center" type="selection" width="55" :selectable="checkboxSelect" />
  390. <el-table-column align="center" label="销售类型" prop="saleName" show-overflow-tooltip />
  391. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip />
  392. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip />
  393. <el-table-column
  394. align="center"
  395. label="产品型号"
  396. prop="specification"
  397. min-width="160"
  398. show-overflow-tooltip
  399. />
  400. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip />
  401. </el-table>
  402. <div class="pagination clearfix" style="margin-top: 10px">
  403. <div class="fr">
  404. <el-pagination
  405. :current-page="currentPage"
  406. :page-size="10"
  407. background
  408. layout="prev, pager, next"
  409. :total="listTotal"
  410. @current-change="handleTableCurrentChange"
  411. />
  412. </div>
  413. </div>
  414. </div>
  415. <div class="buttons">
  416. <el-button size="small" type="primary" @click="addAllGoods">全部添加</el-button>
  417. <el-button size="small" type="primary" @click="addGoods">添&emsp;加</el-button>
  418. <el-button size="small" type="danger" @click="deleteGoods">删&emsp;除</el-button>
  419. <el-button size="small" type="danger" @click="deleteAllGoods">全部删除</el-button>
  420. </div>
  421. <div class="table">
  422. <el-table
  423. :data="rightGoodsList"
  424. element-loading-text="Loading"
  425. border
  426. fit
  427. highlight-current-row
  428. stripe
  429. height="400"
  430. @selection-change="rightSelectionChange"
  431. >
  432. <el-table-column align="center" type="selection" width="55" />
  433. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip />
  434. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip />
  435. <el-table-column
  436. align="center"
  437. label="产品型号"
  438. prop="specification"
  439. min-width="160"
  440. show-overflow-tooltip
  441. />
  442. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip />
  443. <el-table-column align="center" prop="saleName" label="销售类型" show-overflow-tooltip />
  444. </el-table>
  445. </div>
  446. </div>
  447. <span slot="footer" class="dialog-footer">
  448. <el-button @click="closeDialog">取 消</el-button>
  449. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  450. </span>
  451. </el-dialog>
  452. <el-dialog
  453. title="商用工程登录项目"
  454. :visible.sync="visible"
  455. width="60%"
  456. :modal-append-to-body="true"
  457. :append-to-body="true"
  458. :close-on-click-modal="false"
  459. @close="onClose"
  460. >
  461. <div>
  462. <el-row :gutter="20">
  463. <el-form ref="formData" :model="formData" label-width="0" :inline="false" size="small">
  464. <el-col :span="6">
  465. <el-form-item prop="projectNo">
  466. <el-input v-model="formData.projectNo" placeholder="请输入项目编号" />
  467. </el-form-item>
  468. </el-col>
  469. <el-col :span="6">
  470. <el-form-item prop="projectName">
  471. <el-input v-model="formData.projectName" placeholder="请输入项目名称" />
  472. </el-form-item>
  473. </el-col>
  474. <el-col :span="6">
  475. <el-form-item prop="address">
  476. <el-input v-model="formData.address" placeholder="请输入项目地址" />
  477. </el-form-item>
  478. </el-col>
  479. <el-col :span="6" style="text-align: right;">
  480. <el-button size="small" @click="currentPage2 = 1; getLoginOrderList()">查询</el-button>
  481. <el-button size="small" type="primary" @click="resetGoodsScreenForm2">重置</el-button></el-col>
  482. </el-form>
  483. </el-row>
  484. <div>
  485. <zj-table
  486. ref="tableEl"
  487. style="margin-bottom: 20px"
  488. :is-drop="true"
  489. :columns="columns"
  490. :table-data="tableData"
  491. :table-attributes="{
  492. border: true,
  493. maxHeight: '600px'
  494. }"
  495. />
  496. <div class="fr">
  497. <el-pagination
  498. :current-page="currentPage2"
  499. :page-sizes="[10, 20, 30, 50]"
  500. :page-size="10"
  501. layout="total, sizes, prev, pager, next, jumper"
  502. :total="listTotal2"
  503. @size-change="handleSizeChange"
  504. @current-change="handleCurrentChange"
  505. />
  506. </div>
  507. </div>
  508. </div>
  509. <span slot="footer">
  510. <el-button @click="onClose">取 消</el-button>
  511. <el-button type="primary" @click="submitAddOrder">确 定</el-button>
  512. </span>
  513. </el-dialog>
  514. </div>
  515. </template>
  516. <script>
  517. import { getEnginDetail, getRetailProductList, addEngin, editEngin, submitEngin, delItem, getLoginOrderList } from '@/api/supply/engin'
  518. import { getDictList, getTypeList, getSalesmanList, getDealerList } from '@/api/common'
  519. export default {
  520. name: 'EnginForm',
  521. componentName: 'EnginForm',
  522. props: ['listItem'],
  523. data() {
  524. return {
  525. goodsList: [],
  526. mainForm: {
  527. orderNum: '',
  528. orderDate: '',
  529. // mainId: '102',
  530. jxsNum: '',
  531. enginName: '',
  532. machineType: '',
  533. jxsName: '',
  534. jxsId: '',
  535. company: '',
  536. address: '',
  537. enginNum: '',
  538. factoryNum: '',
  539. loginType: '',
  540. linkman: '',
  541. phone: '',
  542. tel: '',
  543. remark: '',
  544. salesMan: '',
  545. createMan: '',
  546. createDate: '',
  547. contractDate: '',
  548. tradeCategory: '',
  549. power: '',
  550. greeRemark: '',
  551. greeReply: '',
  552. fileNo: ''
  553. },
  554. mainFormRules: {
  555. salesMan: [{ required: true, message: '请选择业务员', trigger: 'change' }],
  556. jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
  557. enginName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
  558. jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
  559. company: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
  560. address: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
  561. enginNum: [{ required: true, message: '请输入工程编号', trigger: 'blur' }],
  562. loginType: [{ required: true, message: '请输入工程登录类型', trigger: 'blur' }],
  563. tradeCategory: [{ required: true, message: '请选择行业类别', trigger: 'change' }]
  564. },
  565. loginTypeList: [],
  566. powerList: [],
  567. machineTypeList: [],
  568. tradeCategoryList: [
  569. { value: '房地产', label: '房地产' },
  570. { value: '公共建筑', label: '公共建筑' },
  571. { value: '工业制造', label: '工业制造' },
  572. { value: '商业项目', label: '商业项目' },
  573. { value: '采暖及清洁能源', label: '采暖及清洁能源' },
  574. { value: '轨道交通', label: '轨道交通' },
  575. { value: '数据通讯', label: '数据通讯' },
  576. { value: '冷冻冷藏', label: '冷冻冷藏' },
  577. { value: '高端制造', label: '高端制造' },
  578. { value: '医院医疗', label: '医院医疗' },
  579. { value: '其他', label: '其他' }
  580. ],
  581. btnLoading: false,
  582. typeList: [],
  583. salesTypeList: [],
  584. salesmanList: [],
  585. dealerList: [],
  586. isShowGoodsDialog: false,
  587. goodsScreenForm: {
  588. proNum: '',
  589. proName: '',
  590. proModel: '',
  591. price1: '',
  592. price2: '',
  593. salesType: ''
  594. },
  595. currentPage: 1,
  596. listTotal: 0,
  597. leftGoodsList: [],
  598. rightGoodsList: [],
  599. leftSelection: [],
  600. rightSelection: [],
  601. examineStatus: '',
  602. visible: false,
  603. currentPage2: 1,
  604. pageSize2: 10,
  605. listTotal2: 0,
  606. formData: {
  607. address: '',
  608. projectName: '',
  609. projectNo: ''
  610. },
  611. tableData: [],
  612. current: ''
  613. }
  614. },
  615. computed: {
  616. isDealer() {
  617. return JSON.parse(localStorage.getItem('supply_user')).isCustomer
  618. },
  619. columns() {
  620. return [
  621. {
  622. columnAttributes: {
  623. label: '操作',
  624. width: 45
  625. },
  626. render: (h, { row, column, index }) => {
  627. return (
  628. <div>
  629. <el-radio style='margin-left:20px' value={this.current} label={row.id} onChange={(val) => {
  630. this.current = row.id
  631. }}>{}</el-radio>
  632. </div>
  633. )
  634. }
  635. },
  636. {
  637. columnAttributes: {
  638. label: '项目编号',
  639. prop: 'projectNo',
  640. width: 100
  641. }
  642. },
  643. {
  644. columnAttributes: {
  645. label: '项目名称',
  646. prop: 'projectName',
  647. width: 200
  648. }
  649. },
  650. {
  651. columnAttributes: {
  652. label: '项目地址',
  653. prop: 'address'
  654. }
  655. }
  656. ]
  657. }
  658. },
  659. watch: {
  660. goodsList: {
  661. deep: true,
  662. immediate: true,
  663. handler(val, oval) {
  664. val.forEach(item => {
  665. item.myTotalAmount = (item.price || 0) * (item.qty || 0)
  666. item.sums1 = ['number', 'directTransferQty', 'qty', 'enginNum', 'oldQty', 'hasSendQty']
  667. item.sums2 = ['myTotalAmount', 'payAmount', 'price', 'payRebateAmount', 'discAmount']
  668. })
  669. }
  670. }
  671. },
  672. async created() {
  673. await this.getSalesmanList()
  674. this.getDictList()
  675. this.getTypeList()
  676. this.getDealerList()
  677. if (this.listItem) {
  678. this.getDetail()
  679. } else {
  680. this.mainForm.jxsNum = JSON.parse(localStorage.getItem('supply_user')).customerNumber
  681. this.mainForm.jxsName = JSON.parse(localStorage.getItem('supply_user')).customerName
  682. this.mainForm.createMan = JSON.parse(localStorage.getItem('supply_user')).nickName
  683. this.mainForm.createDate = this.getDate(0)
  684. this.mainForm.contractDate = this.getDate(1)
  685. }
  686. },
  687. methods: {
  688. // 返回列表
  689. goBack() {
  690. this.$emit('backListFormDetail')
  691. },
  692. getLoginOrderList() {
  693. getLoginOrderList({
  694. pageNum: this.currentPage2,
  695. pageSize: this.pageSize2,
  696. ...this.formData
  697. }).then(res => {
  698. this.tableData = res.data.records
  699. this.listTotal2 = res.data.total
  700. })
  701. },
  702. getDate(addYear) {
  703. var date = new Date()
  704. var seperator1 = '-'
  705. var year = date.getFullYear() + addYear
  706. var month = date.getMonth() + 1
  707. var strDate = date.getDate()
  708. if (month >= 1 && month <= 9) {
  709. month = '0' + month
  710. }
  711. if (strDate >= 0 && strDate <= 9) {
  712. strDate = '0' + strDate
  713. }
  714. var currentdate = year + seperator1 + month + seperator1 + strDate
  715. return currentdate
  716. },
  717. // 获取详情
  718. getDetail() {
  719. getEnginDetail({ id: this.listItem.enginInfoId }).then(res => {
  720. const data = res.data
  721. this.mainForm.orderNum = data.enginInfoNo
  722. this.mainForm.orderDate = data.orderDate
  723. // this.mainForm.mainId = data.productCategoryId;
  724. this.mainForm.jxsNum = data.customerNumber
  725. this.mainForm.enginName = data.projectName
  726. this.mainForm.machineType = data.machineType
  727. this.mainForm.jxsName = data.customerName
  728. this.mainForm.company = data.useUnit
  729. this.mainForm.tradeCategory = data.tradeCategory
  730. this.mainForm.address = data.installAddress
  731. this.mainForm.enginNum = data.projectNo
  732. this.mainForm.factoryNum = data.enginFactoryNo
  733. this.mainForm.loginType = data.enginSignType
  734. this.mainForm.linkman = data.linkman
  735. this.mainForm.phone = data.phone
  736. this.mainForm.tel = data.tel
  737. this.mainForm.remark = data.remark
  738. this.mainForm.salesMan = data.serviceId
  739. this.mainForm.createMan = data.createName
  740. this.mainForm.createDate = data.createTime
  741. this.mainForm.contractDate = data.contractExpireDate
  742. this.mainForm.power = data.powerCategory
  743. this.mainForm.greeRemark = data.geLiInerNote
  744. this.mainForm.greeReply = data.geLiNote
  745. this.mainForm.fileNo = data.fileNo
  746. this.examineStatus = data.examineStatus
  747. data.items.forEach(item => {
  748. item.cantDel = true
  749. item.cid = item.id
  750. })
  751. this.goodsList = data.items
  752. })
  753. },
  754. // 获取经销商列表
  755. getDealerList() {
  756. getDealerList({
  757. pageNum: 1,
  758. pageSize: -1
  759. // bindUser: false
  760. }).then(res => {
  761. this.dealerList = res.data.records
  762. })
  763. },
  764. // 获取产品大类列表
  765. getDictList() {
  766. getDictList({ sysDictEnum: 'PRODUCT_TYPE' }).then(res => {
  767. this.typeList = res.data
  768. })
  769. getDictList({ sysDictEnum: 'MACHINE_TYPE' }).then(res => {
  770. this.machineTypeList = res.data
  771. })
  772. getDictList({ sysDictEnum: 'POWER_CATEGORY' }).then(res => {
  773. this.powerList = res.data
  774. })
  775. getDictList({ sysDictEnum: 'SIGN_TYPE' }).then(res => {
  776. this.loginTypeList = res.data
  777. })
  778. },
  779. // 获取销售类型列表
  780. getTypeList() {
  781. getTypeList({
  782. pageNum: 1,
  783. pageSize: -1
  784. }).then(res => {
  785. this.salesTypeList = res.data.records
  786. })
  787. },
  788. async getSalesmanList() {
  789. const res = await getSalesmanList({
  790. pageNum: 1,
  791. pageSize: -1,
  792. isCustomer: 0,
  793. status: true
  794. })
  795. this.salesmanList = res.data.records
  796. },
  797. changeDealer() {
  798. if (this.mainForm.jxsNum) {
  799. const jxsItem = this.dealerList.find(o => o.number == this.mainForm.jxsNum)
  800. this.mainForm.jxsName = jxsItem.name
  801. this.mainForm.jxsId = jxsItem.id
  802. } else {
  803. this.mainForm.jxsName = ''
  804. this.mainForm.jxsId = ''
  805. }
  806. },
  807. changeSaleType(index) {
  808. if (this.goodsList[index].saleTypeId) {
  809. const obj = this.salesTypeList.find(o => o.id == this.goodsList[index].saleTypeId)
  810. this.goodsList[index].saleTypeName = obj.saleName
  811. this.goodsList[index].saleTypeCode = obj.saleCode
  812. } else {
  813. this.goodsList[index].saleTypeName = ''
  814. this.goodsList[index].saleTypeCode = ''
  815. }
  816. },
  817. // 获取商品列表
  818. getGoodsList() {
  819. getRetailProductList({
  820. pageNum: this.currentPage,
  821. pageSize: 10,
  822. saleId: this.goodsScreenForm.salesType,
  823. materialCode: this.goodsScreenForm.proNum,
  824. materialName: this.goodsScreenForm.proName,
  825. specification: this.goodsScreenForm.proModel,
  826. price1: this.goodsScreenForm.price1,
  827. price2: this.goodsScreenForm.price2,
  828. customerId: this.listItem ? this.listItem.customerId : ''
  829. }).then(res => {
  830. const oldGoodsList = this.goodsList
  831. const newGoodsList = res.data.records
  832. for (let i = 0; i < oldGoodsList.length; i++) {
  833. const oldItem = oldGoodsList[i]
  834. for (let j = 0; j < newGoodsList.length; j++) {
  835. const newItem = newGoodsList[j]
  836. if (newItem.id === oldItem.id) {
  837. newGoodsList[j].selected = true
  838. break
  839. }
  840. }
  841. }
  842. res.data.records.forEach(item => {
  843. item.materialName = item.name
  844. item.materialCode = item.number
  845. item.saleTypeName = item.saleName
  846. item.unit = item.baseUnit
  847. item.price = item.batchPrice
  848. item.tax = item.taxRate
  849. item.isDirectTransfer = false
  850. item.directTransferQty = ''
  851. item.status1 = ''
  852. item.status2 = ''
  853. item.rebateAmount = ''
  854. item.rebateRate = ''
  855. item.productPriceId = item.id
  856. // item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
  857. })
  858. this.leftGoodsList = res.data.records
  859. this.listTotal = res.data.total
  860. })
  861. },
  862. // 查询重复值并禁选
  863. checkboxSelect(row, rowIndex) {
  864. if (row.selected) {
  865. return false // 禁用
  866. } else {
  867. return true // 不禁用
  868. }
  869. },
  870. // 点击 选择商品
  871. openDialog() {
  872. this.isShowGoodsDialog = true
  873. this.getGoodsList()
  874. },
  875. // 提交筛选表单
  876. submitGoodsScreenForm() {
  877. this.currentPage = 1
  878. this.getGoodsList()
  879. },
  880. // 重置筛选表单
  881. resetGoodsScreenForm() {
  882. this.$refs.goodsScreenForm.resetFields()
  883. this.currentPage = 1
  884. this.getGoodsList()
  885. },
  886. // 更改列表当前页
  887. handleTableCurrentChange(val) {
  888. this.currentPage = val
  889. this.getGoodsList()
  890. },
  891. // 关闭 弹窗
  892. closeDialog() {
  893. this.isShowGoodsDialog = false
  894. },
  895. // 左侧列表选择
  896. leftSelectionChange(val) {
  897. this.leftSelection = val
  898. },
  899. // 右侧列表选择
  900. rightSelectionChange(val) {
  901. this.rightSelection = val
  902. },
  903. // 数组去重
  904. delRepeat(arr1, arr2) {
  905. const allArr = arr1.concat(arr2) // 两个数组对象合并
  906. const newArr = [] // 存放去重后数据的新数组
  907. for (let i = 0; i < allArr.length; i++) {
  908. // 循环allArr数组对象的内容
  909. let flag = true // 建立标记,判断数据是否重复,true为不重复
  910. for (let j = 0; j < newArr.length; j++) {
  911. // 循环新数组的内容
  912. if (allArr[i].id == newArr[j].id) {
  913. // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  914. flag = false
  915. }
  916. }
  917. if (flag) {
  918. // 判断是否重复
  919. newArr.push(allArr[i]) // 不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  920. }
  921. }
  922. return newArr
  923. },
  924. // 全部添加
  925. addAllGoods() {
  926. this.rightGoodsList = this.delRepeat(this.leftGoodsList, this.rightGoodsList)
  927. },
  928. // 添加
  929. addGoods() {
  930. this.rightGoodsList = this.delRepeat(this.leftSelection, this.rightGoodsList)
  931. },
  932. // 删除
  933. deleteGoods() {
  934. const rightGoodsList = this.rightGoodsList
  935. const rightSelection = this.rightSelection
  936. for (let i = 0; i < rightGoodsList.length; i++) {
  937. for (let j = 0; j < rightSelection.length; j++) {
  938. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  939. this.rightGoodsList.splice(i, 1)
  940. }
  941. }
  942. }
  943. },
  944. // 全部删除
  945. deleteAllGoods() {
  946. this.rightGoodsList = []
  947. },
  948. // 确定 添加产品
  949. submitAddGoods() {
  950. // this.goodsList = this.delRepeat(this.rightGoodsList, this.goodsList);
  951. this.goodsList = this.goodsList.concat(this.rightGoodsList)
  952. this.goodsList.forEach(k => {
  953. if (!k.qty) {
  954. k.qty = 0
  955. }
  956. if (!k.cid) {
  957. k.cid = ''
  958. }
  959. })
  960. this.isShowGoodsDialog = false
  961. this.leftGoodsList = []
  962. this.rightGoodsList = []
  963. },
  964. // 删除产品
  965. deleteItem(index, row, id) {
  966. // id id存在就说明这个货品已经引用过了
  967. // if (this.listItem && this.examineStatus === 'OK' && id) {
  968. // this.$errorMsg('已审核通过的型号不能删除')
  969. // return
  970. // }
  971. if (id) {
  972. delItem({
  973. enginInfoNo: row.enginInfoNo,
  974. itemId: row.id
  975. }).then(res => {
  976. this.goodsList.splice(index, 1)
  977. this.$successMsg('存在的货品删除成功')
  978. })
  979. } else {
  980. this.goodsList.splice(index, 1)
  981. this.$successMsg('删除成功')
  982. }
  983. },
  984. // 导入产品
  985. getImportList(data) {
  986. this.goodsList = this.goodsList.concat(data)
  987. },
  988. clickSubmitForm(type) {
  989. this.btnLoading = true
  990. this.$refs.mainForm.validate(valid => {
  991. if (valid) {
  992. for (let i = 0; i < this.goodsList.length; i++) {
  993. if (!this.goodsList[i].saleTypeId) {
  994. this.$errorMsg('请选择销售类型')
  995. return
  996. }
  997. console.log(this.goodsList[i].qty)
  998. if (this.goodsList[i].qty == null || this.goodsList[i].qty === '' || Number(this.goodsList[i].qty) < 0) {
  999. this.$errorMsg('数量不能为空或者小于0')
  1000. return
  1001. }
  1002. if (!this.goodsList[i].materialNumber) {
  1003. return
  1004. }
  1005. }
  1006. const goodsList = JSON.parse(JSON.stringify(this.goodsList))
  1007. goodsList.forEach(item => {
  1008. delete item.productList
  1009. delete item.id
  1010. })
  1011. const saleManItem = this.mainForm.salesMan
  1012. ? this.salesmanList.find(o => o.adminUserId == this.mainForm.salesMan)
  1013. : ''
  1014. const params = {
  1015. // orderDate: this.mainForm.orderDate + ' 00:00:00',
  1016. // mainId: this.mainForm.mainId,
  1017. projectName: this.mainForm.enginName,
  1018. machineType: this.mainForm.machineType,
  1019. useUnit: this.mainForm.company,
  1020. tradeCategory: this.mainForm.tradeCategory,
  1021. installAddress: this.mainForm.address,
  1022. projectNo: this.mainForm.enginNum,
  1023. enginFactoryNo: this.mainForm.factoryNum,
  1024. enginSignType: this.mainForm.loginType,
  1025. linkman: this.mainForm.linkman,
  1026. phone: this.mainForm.phone,
  1027. serviceId: this.mainForm.salesMan,
  1028. serviceName: saleManItem.nickName,
  1029. tel: this.mainForm.tel,
  1030. remark: this.mainForm.remark,
  1031. contractExpireDate: this.mainForm.contractDate,
  1032. powerCategory: this.mainForm.power,
  1033. geLiInerNote: this.mainForm.greeRemark,
  1034. geLiNote: this.mainForm.greeReply,
  1035. fileNo: this.mainForm.fileNo,
  1036. items: goodsList
  1037. }
  1038. console.log(params)
  1039. if (type === 1) {
  1040. if (this.listItem) {
  1041. params.enginInfoId = this.listItem.enginInfoId
  1042. editEngin(params)
  1043. .then(res => {
  1044. this.$successMsg('编辑成功')
  1045. this.goBack()
  1046. })
  1047. .finally(() => {
  1048. this.btnLoading = false
  1049. })
  1050. } else {
  1051. params.customerNumber = this.mainForm.jxsNum
  1052. params.customerName = this.mainForm.jxsName
  1053. params.customerId = this.mainForm.jxsId
  1054. addEngin(params)
  1055. .then(res => {
  1056. this.$successMsg('保存成功')
  1057. this.goBack()
  1058. })
  1059. .finally(() => {
  1060. this.btnLoading = false
  1061. })
  1062. }
  1063. } else {
  1064. if (this.listItem) {
  1065. params.enginInfoId = this.listItem.enginInfoId
  1066. } else {
  1067. params.customerNumber = this.mainForm.jxsNum
  1068. params.customerName = this.mainForm.jxsName
  1069. params.customerId = this.mainForm.jxsId
  1070. }
  1071. submitEngin(params)
  1072. .then(res => {
  1073. this.$successMsg('提交审核成功')
  1074. this.goBack()
  1075. })
  1076. .finally(() => {
  1077. this.btnLoading = false
  1078. })
  1079. }
  1080. }
  1081. })
  1082. },
  1083. handleSizeChange(val) {
  1084. this.pageSize2 = val
  1085. this.currentPage2 = 1
  1086. this.getLoginOrderList()
  1087. },
  1088. handleCurrentChange(val) {
  1089. this.currentPage2 = val
  1090. this.getLoginOrderList()
  1091. },
  1092. // 重置筛选表单
  1093. resetGoodsScreenForm2() {
  1094. this.$refs.formData.resetFields()
  1095. this.currentPage2 = 1
  1096. this.getLoginOrderList()
  1097. },
  1098. submitAddOrder() {
  1099. const item = this.tableData.find(k => k.id === this.current)
  1100. this.mainForm.enginNum = item.projectNo
  1101. this.mainForm.enginName = item.projectName
  1102. this.mainForm.linkman = item.enginLinkName
  1103. this.mainForm.phone = item.enginLinkMobile
  1104. this.mainForm.address = item.address
  1105. this.onClose()
  1106. },
  1107. onClose() {
  1108. this.$nextTick(() => {
  1109. this.current = ''
  1110. this.$refs.formData.resetFields()
  1111. this.visible = false
  1112. })
  1113. }
  1114. }
  1115. }
  1116. </script>
  1117. <style scoped lang="scss">
  1118. .detail-container {
  1119. width: 100%;
  1120. height: 100%;
  1121. }
  1122. .main-title {
  1123. display: flex;
  1124. justify-content: space-between;
  1125. align-items: center;
  1126. margin-top: 20px;
  1127. height: 60px;
  1128. border-bottom: 1px solid #dcdfe6;
  1129. margin-bottom: 20px;
  1130. .title {
  1131. font-size: 16px;
  1132. font-weight: 600;
  1133. padding-left: 10px;
  1134. }
  1135. }
  1136. .tables {
  1137. display: flex;
  1138. margin-top: 10px;
  1139. .table {
  1140. width: 45%;
  1141. }
  1142. .buttons {
  1143. display: flex;
  1144. flex-direction: column;
  1145. justify-content: center;
  1146. align-items: center;
  1147. padding: 0 10px;
  1148. button {
  1149. margin: 0;
  1150. margin-top: 10px;
  1151. }
  1152. }
  1153. }
  1154. ::v-deep input::-webkit-outer-spin-button,
  1155. ::v-deep input::-webkit-inner-spin-button {
  1156. -webkit-appearance: none;
  1157. }
  1158. ::v-deep input[type='number'] {
  1159. -moz-appearance: textfield;
  1160. }
  1161. </style>