engin_form.vue 34 KB

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