plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

398 lines
13 KiB

1 year ago
1 year ago
1 year ago
  1. <script>
  2. import {
  3. batchRemoveDetailAttribute, batchSaveDetailAttribute,
  4. batchUpdateDetailAttribute,
  5. queryQuoteDetailAttribute,
  6. queryQuoteDetailAttributeItem
  7. } from "../../../../../api/quote/quoteDetailAttribute";
  8. export default {
  9. name: "quoteDetailOtherCost",
  10. props:{
  11. quoteDetail: {
  12. type: Object,
  13. required: true
  14. }
  15. },
  16. model:{
  17. prop: "quoteDetail",
  18. event: "update"
  19. },
  20. data(){
  21. return{
  22. dataList:[],
  23. columns:[
  24. {
  25. userId: this.$store.state.user.name,
  26. functionId: 5011,
  27. serialNumber: '5011Table7ItemNo',
  28. tableId: "5011Table7",
  29. tableName: "物料属性项目表",
  30. columnProp: 'itemNo',
  31. headerAlign: "center",
  32. align: "left",
  33. columnLabel: '属性编码',
  34. columnHidden: false,
  35. columnImage: false,
  36. columnSortable: false,
  37. sortLv: 0,
  38. status: true,
  39. fixed: '',
  40. columnWidth: 110,
  41. },
  42. {
  43. userId: this.$store.state.user.name,
  44. functionId: 5011,
  45. serialNumber: '5011Table7ItemDesc',
  46. tableId: "5011Table7",
  47. tableName: "物料属性项目表",
  48. columnProp: 'itemDesc',
  49. headerAlign: "center",
  50. align: "left",
  51. columnLabel: '属性名称',
  52. columnHidden: false,
  53. columnImage: false,
  54. columnSortable: false,
  55. sortLv: 0,
  56. status: true,
  57. fixed: '',
  58. columnWidth: 180,
  59. },
  60. {
  61. userId: this.$store.state.user.name,
  62. functionId: 5011,
  63. serialNumber: '5011Table7ValueType',
  64. tableId: "5011Table7",
  65. tableName: "物料属性项目表",
  66. columnProp: 'valueType',
  67. headerAlign: "center",
  68. align: "center",
  69. columnLabel: '属性类型',
  70. columnHidden: false,
  71. columnImage: false,
  72. columnSortable: false,
  73. sortLv: 0,
  74. status: true,
  75. fixed: '',
  76. columnWidth: 60,
  77. },
  78. {
  79. userId: this.$store.state.user.name,
  80. functionId: 5011,
  81. serialNumber: '5011TableValue',
  82. tableId: "5011Table",
  83. tableName: "common",
  84. columnProp: 'value',
  85. headerAlign: "center",
  86. align: "center",
  87. columnLabel: '属性值',
  88. columnHidden: false,
  89. columnImage: false,
  90. columnSortable: false,
  91. sortLv: 0,
  92. status: true,
  93. fixed: '',
  94. columnWidth: 100,
  95. },
  96. ],
  97. attribute:{
  98. itemNo: '',
  99. itemDesc: '',
  100. },
  101. updateStatus:false,
  102. dialogVisible:false,
  103. selectionDataList:[],
  104. itemList:[],
  105. selectionList:[],
  106. }
  107. },
  108. methods:{
  109. handleQueryOther(){
  110. let params = {
  111. quoteDetailId: this.quoteDetail.id
  112. }
  113. this.updateStatus = false;
  114. queryQuoteDetailAttribute(params).then(({data})=>{
  115. if (data && data.code === 0){
  116. this.dataList = data.rows;
  117. }else {
  118. this.$message.warning(data.message);
  119. }
  120. }).catch((error)=>{
  121. this.$message.error(error.message);
  122. })
  123. },
  124. handleUpdateAttribute(){
  125. if (this.dataList.length === 0){
  126. this.$message.warning("请先添加属性");
  127. return
  128. }
  129. if (this.updateStatus === false){
  130. this.updateStatus = true;
  131. return
  132. }
  133. // 保存属性
  134. let params = this.dataList.map(item => {
  135. return{
  136. ...item,
  137. updateBy: this.$store.state.user.name,
  138. }
  139. })
  140. batchUpdateDetailAttribute(params).then(({data})=>{
  141. if (data && data.code === 0){
  142. this.$message.success(data.msg);
  143. this.handleQueryOther();
  144. this.updateStatus = false;
  145. }else {
  146. this.$message.warning(data.msg);
  147. }
  148. }).catch((error)=>{
  149. this.$message.error(error);
  150. })
  151. },
  152. handleSaveAttribute(){
  153. this.attribute ={
  154. itemNo: '',
  155. itemDesc: '',
  156. }
  157. this.handleQueryAttributeItem();
  158. this.dialogVisible = true;
  159. },
  160. handleQueryAttributeItem(){
  161. let params = {
  162. ...this.attribute,
  163. quoteDetailId: this.quoteDetail.id,
  164. quoteId: this.quoteDetail.quoteId,
  165. quoteNo: this.quoteDetail.quoteNo,
  166. site: this.quoteDetail.site,
  167. buNo: this.quoteDetail.buNo,
  168. versionNo: this.quoteDetail.versionNo,
  169. quoteDetailItemNo: this.quoteDetail.itemNo,
  170. }
  171. queryQuoteDetailAttributeItem(params).then(({data})=>{
  172. if (data && data.code === 0){
  173. this.itemList = data.rows;
  174. }else {
  175. this.$message.warning(data.msg);
  176. }
  177. }).catch((error)=>{
  178. this.$message.error(error);
  179. })
  180. },
  181. handleRowClick(row,ref){
  182. this.$refs[ref].toggleRowSelection(row,true)
  183. },
  184. handleSelectionChange(val){
  185. this.selectionDataList = val;
  186. },
  187. handleItemSelectionChange(val){
  188. this.selectionList = val;
  189. },
  190. handleAddAttribute(){
  191. if (this.selectionList.length === 0){
  192. this.$message.warning("请先选择属性");
  193. return
  194. }
  195. let params = this.selectionList.map(item => {
  196. return{
  197. ...item,
  198. createBy: this.$store.state.user.name,
  199. }
  200. })
  201. batchSaveDetailAttribute(params).then(({data})=>{
  202. if (data && data.code === 0) {
  203. this.$message.success(data.msg);
  204. this.handleQueryOther();
  205. this.handleQueryAttributeItem();
  206. }else {
  207. this.$message.warning(data.msg);
  208. }
  209. }).catch((error)=>{
  210. this.$message.error(error);
  211. })
  212. },
  213. handleRemoveAttribute(){
  214. if (this.selectionDataList.length === 0){
  215. this.$message.warning("请先选择属性");
  216. return
  217. }
  218. batchRemoveDetailAttribute(this.selectionDataList).then(({data})=>{
  219. if (data && data.code === 0){
  220. this.$message.success(data.msg);
  221. this.handleQueryOther();
  222. this.handleQueryAttributeItem();
  223. }else {
  224. this.$message.warning(data.msg);
  225. }
  226. }).catch((error)=>{
  227. this.$message.error(error);
  228. })
  229. },
  230. },
  231. created() {
  232. if (this.quoteDetail && this.quoteDetail.id){
  233. this.handleQueryOther()
  234. }
  235. },
  236. watch:{
  237. 'quoteDetail.id'(newVal, oldVal){
  238. this.handleQueryOther()
  239. },
  240. }
  241. }
  242. </script>
  243. <template>
  244. <div>
  245. <el-button type="primary" :disabled="quoteDetail.status === '下达'" @click="handleSaveAttribute">新增</el-button>
  246. <el-button type="primary" :disabled="quoteDetail.status === '下达'" @click="handleUpdateAttribute">{{updateStatus?'保存':'编辑'}}</el-button>
  247. <el-table :data="dataList" style="width: 100%" border :height="420">
  248. <el-table-column
  249. v-for="(item,index) in columns" :key="index"
  250. :sortable="item.columnSortable"
  251. :prop="item.columnProp"
  252. :header-align="item.headerAlign"
  253. :show-overflow-tooltip="item.showOverflowTooltip"
  254. :align="item.align"
  255. :fixed="item.fixed===''?false:item.fixed"
  256. :min-width="item.columnWidth"
  257. :label="item.columnLabel">
  258. <template slot-scope="scope">
  259. <span v-if="!item.columnHidden">
  260. <template v-if="item.columnProp==='valueChooseFlag'">{{ scope.row[item.columnProp] === 'Y' ? '' : '' }}</template>
  261. <template v-else-if="item.columnProp==='value' && updateStatus === true && scope.row.valueTypeDb==='T' && scope.row.valueChooseFlag==='Y'">
  262. <el-select v-model="scope.row['textValue']" placeholder="请选择" style="width: 100%">
  263. <el-option :label="available.availableValue" :value="available.availableValue" :key="available.valueNo" v-for="(available) in scope.row.availableList"></el-option>
  264. </el-select>
  265. </template>
  266. <template v-else-if="item.columnProp==='value' && updateStatus === true && scope.row.valueTypeDb==='N' && scope.row.valueChooseFlag==='Y'">
  267. <el-select v-model="scope.row['numValue']" placeholder="请选择" style="width: 100%">
  268. <el-option :label="available.availableValue" :value="available.availableValue" :key="available.valueNo" v-for="(available) in scope.row.availableList"></el-option>
  269. </el-select>
  270. </template>
  271. <template v-else-if="item.columnProp==='value' && updateStatus === true && scope.row.valueTypeDb==='T'">
  272. <el-input v-model="scope.row['textValue']"></el-input>
  273. </template>
  274. <template v-else-if="item.columnProp==='value' && updateStatus === true && scope.row.valueTypeDb==='N'">
  275. <el-input-number style="width: 100%" :controls="false" :step="0" v-model="scope.row['numValue']"></el-input-number>
  276. </template>
  277. <template v-else-if="item.columnProp==='value' && scope.row.valueTypeDb==='T'">
  278. <div style="text-align: left">{{ scope.row['textValue'] }}</div>
  279. </template>
  280. <template v-else-if="item.columnProp==='value' && scope.row.valueTypeDb==='N'">
  281. <div style="text-align: right">{{ scope.row['numValue'] }}</div>
  282. </template>
  283. <template v-else>{{ scope.row[item.columnProp] }}</template>
  284. </span>
  285. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  286. </template>
  287. </el-table-column>
  288. </el-table>
  289. <el-dialog title="属性信息" :visible.sync="dialogVisible" v-drag :close-on-click-modal="false" append-to-body width="1100px">
  290. <el-form ref="form" :model="attribute" label-position="top" label-width="100px">
  291. <el-row :gutter="10">
  292. <el-col :span="4">
  293. <el-form-item label="属性编码">
  294. <el-input v-model="attribute.itemNo"></el-input>
  295. </el-form-item>
  296. </el-col>
  297. <el-col :span="5">
  298. <el-form-item label="属性名称">
  299. <el-input v-model="attribute.itemDesc"></el-input>
  300. </el-form-item>
  301. </el-col>
  302. <el-col :span="3">
  303. <el-form-item label=" ">
  304. <el-button type="primary" @click="handleQueryAttributeItem">查询</el-button>
  305. </el-form-item>
  306. </el-col>
  307. </el-row>
  308. </el-form>
  309. <el-container style="margin-top: 0px;">
  310. <el-main style="width: 350px;padding: 1px">
  311. <span style="font-size: 12px">可选属性</span>
  312. <el-table
  313. height="400px"
  314. :data="itemList"
  315. @selection-change="handleItemSelectionChange"
  316. @row-click="(row)=>handleRowClick(row,'itemTable1')"
  317. border
  318. ref="itemTable1"
  319. style="width: 100%">
  320. <el-table-column
  321. type="selection"
  322. header-align="center"
  323. align="center"
  324. width="50">
  325. </el-table-column>
  326. <el-table-column
  327. prop="itemNo"
  328. header-align="center"
  329. align="center"
  330. min-width="150"
  331. label="属性编码">
  332. </el-table-column>
  333. <el-table-column
  334. prop="itemDesc"
  335. header-align="center"
  336. align="center"
  337. min-width="200"
  338. label="属性名称">
  339. </el-table-column>
  340. </el-table>
  341. </el-main>
  342. <el-main style="width: 10px;padding: 1px">
  343. <div style="margin-top: 200px;margin-left: 18px">
  344. <el-button type="primary" @click="handleAddAttribute">添加>></el-button>
  345. </div>
  346. <div style="margin-top: 15px;margin-left: 18px">
  347. <el-button type="primary" @click="handleRemoveAttribute">删除<<</el-button>
  348. </div>
  349. </el-main>
  350. <el-main style="width: 350px;padding: 1px">
  351. <span style="font-size: 12px">已有属性</span>
  352. <el-table
  353. height="400px"
  354. border
  355. ref="itemTable2"
  356. :data="dataList"
  357. @row-click="(row)=>handleRowClick(row,'itemTable2')"
  358. @selection-change="handleSelectionChange"
  359. style="width: 100%">
  360. <el-table-column
  361. type="selection"
  362. header-align="center"
  363. align="center"
  364. width="50">
  365. </el-table-column>
  366. <el-table-column
  367. prop="itemNo"
  368. header-align="center"
  369. align="left"
  370. min-width="150"
  371. label="属性编码">
  372. </el-table-column>
  373. <el-table-column
  374. prop="itemDesc"
  375. header-align="center"
  376. align="center"
  377. min-width="200"
  378. label="属性名称">
  379. </el-table-column>
  380. </el-table>
  381. </el-main>
  382. </el-container>
  383. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  384. <el-button type="primary" @click="dialogVisible = false">关闭</el-button>
  385. </el-footer>
  386. </el-dialog>
  387. </div>
  388. </template>
  389. <style scoped>
  390. .el-table /deep/ .cell{
  391. height: auto;
  392. line-height: 1.5;
  393. }
  394. </style>